Skip to content

Commit 42497b3

Browse files
authored
Merge pull request #1305 from Jinjiang/zh
[docs][zh] update
2 parents 01cf322 + fc5b799 commit 42497b3

File tree

4 files changed

+48
-11
lines changed

4 files changed

+48
-11
lines changed

Diff for: docs/zh/guide/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Vue Loader 的配置和其它的 loader 不太一样。除了通过一条规则
1212

1313
``` js
1414
// webpack.config.js
15-
const { VueLoaderPlugin } = require('vue-loader')
15+
const VueLoaderPlugin = require('vue-loader/lib/plugin')
1616

1717
module.exports = {
1818
module: {
@@ -38,7 +38,7 @@ module.exports = {
3838
``` js
3939
// webpack.config.js
4040
const path = require('path')
41-
const { VueLoaderPlugin } = require('vue-loader')
41+
const VueLoaderPlugin = require('vue-loader/lib/plugin')
4242

4343
module.exports = {
4444
mode: 'development',

Diff for: docs/zh/guide/pre-processors.md

+18-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ npm install -D postcss-loader
142142
{
143143
test: /\.css$/,
144144
use: [
145-
'style-loader',
145+
'vue-style-loader',
146146
{
147147
loader: 'css-loader',
148148
options: { importLoaders: 1 }
@@ -172,6 +172,23 @@ npm install -D babel-core babel-loader
172172

173173
Babel 的配置可以通过 `.babelrc``babel-loader` 选项来完成。
174174

175+
### 排除 node_modules
176+
177+
`exclude: /node_modules/` 在应用于 `.js` 文件的 JS 转译规则 (例如 `babel-loader`) 中是蛮常见的。鉴于 v15 中的推导变化,如果你导入一个 `node_modules` 内的 Vue 单文件组件,它的 `<script>` 部分在转译时将会被排除在外。
178+
179+
为了确保 JS 的转译应用到 `node_modules` 的 Vue 单文件组件,你需要通过使用一个排除函数将它们加入白名单:
180+
181+
``` js
182+
{
183+
test: /\.js$/,
184+
loader: 'babel-loader',
185+
exclude: file => (
186+
/node_modules/.test(file) &&
187+
!/\.vue\.js/.test(file)
188+
)
189+
}
190+
```
191+
175192
## TypeScript
176193

177194
``` bash

Diff for: docs/zh/migrating.md

+21-8
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ sidebarDepth: 2
66
# 从 v14 迁移
77

88
::: tip 注意
9-
我们正在升级 Vue CLI 3 beta 的过程中,并使用了 webpack 4 + Vue Loader 15,所以如果你计划升级到 Vue CLI 3 的话,可能需要等待。
9+
我们正在升级 Vue CLI 3 beta 的过程中,并使用了 webpack 4 + Vue Loader v15,所以如果你计划升级到 Vue CLI 3 的话,可能需要等待。
1010
:::
1111

1212
## 值得注意的不兼容变更
1313

1414
### 现在你需要一个插件
1515

16-
Vue Loader 15 现在需要配合一个 webpack 插件才能正确使用:
16+
Vue Loader v15 现在需要配合一个 webpack 插件才能正确使用:
1717

1818
``` js
1919
// webpack.config.js
20-
const { VueLoaderPlugin } = require('vue-loader')
20+
const VueLoaderPlugin = require('vue-loader/lib/plugin')
2121

2222
module.exports = {
2323
// ...
@@ -29,7 +29,7 @@ module.exports = {
2929

3030
### Loader 推导
3131

32-
现在 Vue Loader 15 使用了一个不一样的策略来推导语言块使用的 loader。
32+
现在 Vue Loader v15 使用了一个不一样的策略来推导语言块使用的 loader。
3333

3434
`<style lang="less">` 举例:在 v14 或更低版本中,它会尝试使用 `less-loader` 加载这个块,并在其后面隐式地链上 `css-loader``vue-style-loader`,这一切都使用内联的 loader 字符串。
3535

@@ -57,6 +57,23 @@ module.exports = {
5757

5858
v15 也允许为 loader 使用非序列化的选项,这种选项在之前的版本中是无法使用的。
5959

60+
### 从依赖中导入单文件组件
61+
62+
`exclude: /node_modules/` 在运用于 `.js` 文件的 JS 转译规则 (例如 `babel-loader`) 中是蛮常见的。鉴于 v15 中的推导变化,如果你导入一个 `node_modules` 内的 Vue 单文件组件,它的 `<script>` 部分在转译时将会被排除在外。
63+
64+
为了确保 JS 的转译应用到 `node_modules` 的 Vue 单文件组件,你需要通过使用一个排除函数将它们加入白名单:
65+
66+
``` js
67+
{
68+
test: /\.js$/,
69+
loader: 'babel-loader',
70+
exclude: file => (
71+
/node_modules/.test(file) &&
72+
!/\.vue\.js/.test(file)
73+
)
74+
}
75+
```
76+
6077
### 模板预处理
6178

6279
v14 或更低版本使用 [consolidate](https://github.com/tj/consolidate.js/) 来编译 `<template lang="xxx">`。v15 现在取而代之的是使用 webpack loader 为它们应用预处理器。
@@ -244,10 +261,6 @@ externals: nodeExternals({
244261

245262
- `transformToRequire` (现在改名为 `transformAssetUrls`)
246263

247-
下列选项已经被改为 `resourceQuery`
248-
249-
- `shadowMode` (现在使用内联资源查询语句,例如 `foo.vue?shadow`)
250-
251264
:::tip
252265
想查阅新选项的完整列表,请移步[选项参考](./options.md)
253266
:::

Diff for: docs/zh/options.md

+7
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,10 @@ sidebar: auto
6767
- 默认值:`process.env.NODE_ENV === 'production'`
6868

6969
强制指定为生产环境,即禁止 loader 注入只在开发环境有效的代码 (例如 hot-reload 相关的代码)。
70+
71+
## shadowMode
72+
73+
- 类型:`boolean`
74+
- 默认值:`false`
75+
76+
编译用于 Shadow DOM 内部的组件。在该模式下,组件的样式会被注入到 `this.$root.$options.shadowRoot`,而不是文档的 head 部分。

0 commit comments

Comments
 (0)