You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An object specifying webpack loaders to overwrite the default loaders used for language blocks inside `*.vue` files. The key corresponds to the `lang` attribute for language blocks, if specified. The default `lang` for each type is:
40
28
@@ -45,7 +33,6 @@ module.exports = {
45
33
For example, to use `babel-loader` and `eslint-loader` to process all `<script>` blocks:
46
34
47
35
```js
48
-
// webpack 2.x config
49
36
module: {
50
37
rules: [
51
38
{
@@ -61,17 +48,36 @@ module.exports = {
61
48
}
62
49
```
63
50
51
+
You can also use object or array syntax (note the options must be serializable):
The config format is the same as `loaders`, but `preLoaders` are applied to corresponding language blocks before the default loaders. You can use this to pre-process language blocks - a common use case would be build-time i18n.
70
77
71
78
### postLoaders
72
79
73
80
- type: `{ [lang: string]: string }`
74
-
- only supported in 10.3.0+
75
81
76
82
The config format is the same as `loaders`, but `postLoaders` are applied after the default loaders. You can use this to post-process language blocks. However note that this is a bit more complicated:
77
83
@@ -81,7 +87,7 @@ module.exports = {
81
87
82
88
### postcss
83
89
84
-
> Note: in 11.0.0+ it is recommended to use a PostCSS config file instead. [The usage is the same as `postcss-loader`](https://github.com/postcss/postcss-loader#usage).
90
+
> Note: It is recommended to use a PostCSS config file instead so that your styles in vue files and normal CSS can share the same config. [The usage is the same as `postcss-loader`](https://github.com/postcss/postcss-loader#usage).
85
91
86
92
- type: `Array` or `Function` or `Object`
87
93
@@ -208,21 +214,6 @@ module.exports = {
208
214
Example configuration:
209
215
210
216
``` js
211
-
// webpack 1
212
-
vue: {
213
-
buble: {
214
-
// enable object spread operator
215
-
// NOTE: you need to provide Object.assign polyfill yourself!
Copy file name to clipboardExpand all lines: docs/en/workflow/linting.md
+9-56Lines changed: 9 additions & 56 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,14 +2,16 @@
2
2
3
3
You may have been wondering how do you lint your code inside `*.vue` files, since they are not JavaScript. We will assume you are using [ESLint](https://eslint.org/) (if you are not, you should!).
4
4
5
-
You will also need the [eslint-plugin-html](https://github.com/BenoitZugmeyer/eslint-plugin-html) which supports extracting and linting the JavaScript inside `*.vue` files.
5
+
You will also need the official [eslint-plugin-vue](https://github.com/vuejs/eslint-plugin-vue) which supports linting both the template and script parts of Vue files.
6
6
7
-
Make sure to include the plugin in your ESLint config:
7
+
Make sure to use the plugin's included config in your ESLint config:
8
8
9
9
```json
10
-
"plugins": [
11
-
"html"
12
-
]
10
+
{
11
+
"extends": [
12
+
"plugin:vue/essential"
13
+
]
14
+
}
13
15
```
14
16
15
17
Then from the command line:
@@ -24,68 +26,19 @@ Another option is using [eslint-loader](https://github.com/MoOx/eslint-loader) s
24
26
npm install eslint eslint-loader --save-dev
25
27
```
26
28
27
-
```js
28
-
// webpack.config.js
29
-
module.exports= {
30
-
// ... other options
31
-
module: {
32
-
loaders: [
33
-
{
34
-
test:/\.vue$/,
35
-
loader:'vue!eslint'
36
-
}
37
-
]
38
-
}
39
-
}
40
-
```
41
-
42
-
Note that webpack loader chains are applied **right-first**. Make sure to apply `eslint` before `vue` so we are linting the pre-compile source code.
43
-
44
-
One thing we need to consider is using third party `*.vue` components shipped in NPM packages. In such case, we want to use `vue-loader` to process the third party component, but do not want to lint it. We can separate the linting into webpack's [preLoaders](https://webpack.github.io/docs/loaders.html#loader-order):
0 commit comments