Skip to content

Commit bc17a9b

Browse files
committed
Merge remote-tracking branch 'upstream/master' into working
2 parents 94ae2aa + 1e3dc16 commit bc17a9b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+604
-447
lines changed

Diff for: docs/en/README.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,37 @@
22

33
### What is `vue-loader`?
44

5-
`vue-loader` is a loader for Webpack that can transform Vue components written in the following format into a plain JavaScript module:
5+
`vue-loader` is a loader for webpack that can transform Vue components written in the following format into a plain JavaScript module:
66

77
![screenshot](http://blog.evanyou.me/images/vue-component.png)
88

99
There are many cool features provided by `vue-loader`:
1010

1111
- ES2015 enabled by default;
12-
- Allows using other Webpack loaders for each part of a Vue component, for example SASS for `<style>` and Jade for `<template>`;
12+
- Allows using other webpack loaders for each part of a Vue component, for example SASS for `<style>` and Jade for `<template>`;
1313
- Allows custom sections in a .vue file that can have custom loader chains applied to them
14-
- Treat static assets referenced in `<style>` and `<template>` as module dependencies and handle them with Webpack loaders;
14+
- Treat static assets referenced in `<style>` and `<template>` as module dependencies and handle them with webpack loaders;
1515
- Can simulate scoped CSS for each component;
1616
- Supports component hot-reloading during development.
1717

18-
In a nutshell, the combination of Webpack and `vue-loader` gives you a modern, flexible and extremely powerful front-end workflow for authoring Vue.js applications.
18+
In a nutshell, the combination of webpack and `vue-loader` gives you a modern, flexible and extremely powerful front-end workflow for authoring Vue.js applications.
1919

20-
### What is Webpack?
20+
### What is webpack?
2121

22-
If you are already familiar with Webpack, feel free to skip the following explanation. But for those of you who are new to Webpack, here's a quick intro:
22+
If you are already familiar with webpack, feel free to skip the following explanation. But for those of you who are new to webpack, here's a quick intro:
2323

24-
[Webpack](https://webpack.github.io/) is a module bundler. It takes a bunch of files, treating each as a module, figuring out the dependencies between them, and bundle them into static assets that are ready for deployment.
24+
[webpack](https://webpack.github.io/) is a module bundler. It takes a bunch of files, treating each as a module, figuring out the dependencies between them, and bundle them into static assets that are ready for deployment.
2525

2626
![webpack](https://webpack.github.io/assets/what-is-webpack.png)
2727

28-
For a basic example, imagine we have a bunch of CommonJS modules. They cannot run directly inside the browser, so we need to "bundle" them into a single file that can be included via a `<script>` tag. Webpack can follow the dependencies of the `require()` calls and do that for us.
28+
For a basic example, imagine we have a bunch of CommonJS modules. They cannot run directly inside the browser, so we need to "bundle" them into a single file that can be included via a `<script>` tag. webpack can follow the dependencies of the `require()` calls and do that for us.
2929

30-
But Webpack can do more than that. With "loaders", we can teach Webpack to transform all types of files in any way we want before outputting the final bundle. Some examples include:
30+
But webpack can do more than that. With "loaders", we can teach webpack to transform all types of files in any way we want before outputting the final bundle. Some examples include:
3131

3232
- Transpile ES2015, CoffeeScript or TypeScript modules into plain ES5 CommonJS modules;
3333
- Optionally you can pipe the source code through a linter before doing the compilation;
3434
- Transpile Jade templates into plain HTML and inline it as a JavaScript string;
3535
- Transpile SASS files into plain CSS, then convert it into a JavaScript snippet that insert the resulting CSS as a `<style>` tag;
3636
- Process an image file referenced in HTML or CSS, moved it to the desired destination based on the path configurations, and naming it using its md5 hash.
3737

38-
Webpack is so powerful that when you understand how it works, it can dramatically improve your front-end workflow. Its primary drawback is its verbose and complex configuration; but with this guide you should be able to find solutions for most common issues when using Webpack with Vue.js and `vue-loader`.
38+
webpack is so powerful that when you understand how it works, it can dramatically improve your front-end workflow. Its primary drawback is its verbose and complex configuration; but with this guide you should be able to find solutions for most common issues when using webpack with Vue.js and `vue-loader`.

Diff for: docs/en/configurations/advanced.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ To do that, specify the `loaders` option for `vue-loader`:
1212

1313
> Note that `preLoaders` and `postLoaders` are only supported in 10.3.0+
1414
15-
### Webpack 2.x
15+
### webpack 2.x
1616

1717
``` js
1818
module.exports = {
1919
// other options...
2020
module: {
21-
// module.rules is the same as module.loaders in 1.x
21+
// `module.rules` is the same as `module.loaders` in 1.x
2222
rules: [
2323
{
2424
test: /\.vue$/,
@@ -49,7 +49,7 @@ module.exports = {
4949
postLoaders: {
5050
html: 'babel-loader'
5151
},
52-
52+
5353
// `excludedPreLoaders` should be regex
5454
excludedPreLoaders: /(eslint-loader)/
5555
}
@@ -59,7 +59,7 @@ module.exports = {
5959
}
6060
```
6161

62-
### Webpack 1.x
62+
### webpack 1.x
6363

6464
``` js
6565
// webpack.config.js
@@ -73,7 +73,7 @@ module.exports = {
7373
}
7474
]
7575
},
76-
// vue-loader configurations
76+
// `vue-loader` configurations
7777
vue: {
7878
loaders: {
7979
// same configuration rules as above

Diff for: docs/en/configurations/asset-url.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ will be compiled into:
1414
createElement('img', { attrs: { src: require('../image.png') }})
1515
```
1616

17-
Because `.png` is not a JavaScript file, you will need to configure Webpack to use [file-loader](https://github.com/webpack/file-loader) or [url-loader](https://github.com/webpack/url-loader) to handle them. The project scaffolded with `vue-cli` has also configured this for you.
17+
Because `.png` is not a JavaScript file, you will need to configure webpack to use [file-loader](https://github.com/webpack/file-loader) or [url-loader](https://github.com/webpack/url-loader) to handle them. The project scaffolded with `vue-cli` has also configured this for you.
1818

1919
The benefits of all this are:
2020

21-
1. `file-loader` allows you to designate where to copy and place the asset file, and how to name it using version hashes for better caching. Moreover, this also means **you can just place images next to your `*.vue` files and use relative paths based on the folder structure instead of worrying about deployment URLs**. With proper config, Webpack will auto-rewrite the file paths into correct URLs in the bundled output.
21+
1. `file-loader` allows you to designate where to copy and place the asset file, and how to name it using version hashes for better caching. Moreover, this also means **you can just place images next to your `*.vue` files and use relative paths based on the folder structure instead of worrying about deployment URLs**. With proper config, webpack will auto-rewrite the file paths into correct URLs in the bundled output.
2222

2323
2. `url-loader` allows you to conditionally inline a file as base-64 data URL if they are smaller than a given threshold. This can reduce the amount of HTTP requests for trivial files. If the file is larger than the threshold, it automatically falls back to `file-loader`.

Diff for: docs/en/configurations/custom-blocks.md

+9-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
You can define custom language blocks inside `*.vue` files. The content of a custom block will be processed by the loaders specified in the `loaders` object of `vue-loader` options and then required by the component module. The configuration is similar to what is described in [Advanced Loader Configuration](../configurations/advanced.md), except the matching uses the tag name instead of the `lang` attribute.
66

7-
If a matching loader is found for a custom block, it will be processed; otherwise the custom block will simply be ignored. Additionally, if the found loader returns a function, that function will be called with the component of the `*.vue` file as a parameter.
7+
If a matching loader is found for a custom block, it will be processed; otherwise the custom block will simply be ignored. Additionally, if the found loader returns a function, that function will be called with the component of the `*.vue` file as a parameter.
88

99
## Single docs file example
1010

@@ -41,15 +41,15 @@ comp-a h2 {
4141
#### webpack.config.js
4242

4343
``` js
44-
// Webpack 2.x
44+
// webpack 2.x
4545
var ExtractTextPlugin = require("extract-text-webpack-plugin")
4646

4747
module.exports = {
4848
module: {
4949
rules: [
5050
{
5151
test: /\.vue$/,
52-
loader: 'vue',
52+
loader: 'vue-loader',
5353
options: {
5454
loaders: {
5555
// extract all <docs> content as raw text
@@ -68,11 +68,13 @@ module.exports = {
6868

6969
## Runtime available docs
7070

71+
> Requires 11.3.0+
72+
7173
Here's an example of injecting the `<docs>` custom blocks into the component so that it's available during runtime.
7274

73-
#### docs-loader.js
75+
#### docs-loader.js
7476

75-
In order for the custom block content to be injected, we'll need a custom loader:
77+
In order for the custom block content to be injected, we'll need a custom loader:
7678

7779
``` js
7880
module.exports = function (source, map) {
@@ -94,7 +96,7 @@ module.exports = {
9496
rules: [
9597
{
9698
test: /\.vue$/,
97-
loader: 'vue',
99+
loader: 'vue-loader',
98100
options: {
99101
loaders: {
100102
'docs': docsLoader
@@ -108,7 +110,7 @@ module.exports = {
108110

109111
#### component.vue
110112

111-
We are now able to access the `<docs>` block's content of imported components during runtime.
113+
We are now able to access the `<docs>` block's content of imported components during runtime.
112114

113115
``` html
114116
<template>

Diff for: docs/en/configurations/extract-css.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Note this only extracts `*.vue` files though - CSS imported in JavaScript still
3939

4040
Example config to extract all the processed CSS in all Vue components into a single CSS file:
4141

42-
### Webpack 2.x
42+
### webpack 2.x
4343

4444

4545
``` js
@@ -70,7 +70,7 @@ module.exports = {
7070
}
7171
```
7272

73-
### Webpack 1.x
73+
### webpack 1.x
7474

7575
``` bash
7676
npm install extract-text-webpack-plugin --save-dev

Diff for: docs/en/configurations/pre-processors.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Using Pre-Processors
22

3-
In Webpack, all pre-processors need to be applied with a corresponding loader. `vue-loader` allows you to use other Webpack loaders to process a part of a Vue component. It will automatically infer the proper loaders to use from the `lang` attribute of a language block.
3+
In webpack, all pre-processors need to be applied with a corresponding loader. `vue-loader` allows you to use other webpack loaders to process a part of a Vue component. It will automatically infer the proper loaders to use from the `lang` attribute of a language block.
44

55
### CSS
66

@@ -20,7 +20,7 @@ Under the hood, the text content inside the `<style>` tag will be first compiled
2020

2121
#### sass-loader caveat
2222

23-
Contrary to what its name indicates, [*sass*-loader](https://github.com/jtangelder/sass-loader) parses *SCSS* syntax by default. If you actually want to use the indented *SASS* syntax, you have to configure vue-loader's options for sass-loader accordingly.
23+
Contrary to what its name indicates, [*sass*-loader](https://github.com/jtangelder/sass-loader) parses *SCSS* syntax by default. If you actually want to use the indented *SASS* syntax, you have to configure vue-loader's options for sass-loader accordingly.
2424

2525
```javascript
2626
{
@@ -69,7 +69,7 @@ scss: generateLoaders('sass').concat(
6969
),
7070
```
7171

72-
It is recommended to only include variables, mixins, etc. in this file, to prevent duplicated css in your final, compiled files.
72+
It is recommended to only include variables, mixins, etc. in this file, to prevent duplicated css in your final, compiled files.
7373

7474
### JavaScript
7575

@@ -87,7 +87,7 @@ npm install coffee-loader --save-dev
8787

8888
### Templates
8989

90-
Processing templates is a little different, because most Webpack template loaders such as `pug-loader` return a template function instead of a compiled HTML string. Instead of using `pug-loader`, we can just install the original `pug`:
90+
Processing templates is a little different, because most webpack template loaders such as `pug-loader` return a template function instead of a compiled HTML string. Instead of using `pug-loader`, we can just install the original `pug`:
9191

9292
``` bash
9393
npm install pug --save-dev
@@ -104,12 +104,12 @@ div
104104
105105
### Inline Loader Requests
106106

107-
You can use [Webpack loader requests](https://webpack.github.io/docs/loaders.html#introduction) in the `lang` attribute:
107+
You can use [webpack loader requests](https://webpack.github.io/docs/loaders.html#introduction) in the `lang` attribute:
108108

109109
``` html
110110
<style lang="sass?outputStyle=expanded">
111111
/* use sass here with expanded output */
112112
</style>
113113
```
114114

115-
However, note this makes your Vue component Webpack-specific and not compatible with Browserify and [vueify](https://github.com/vuejs/vueify). **If you intend to ship your Vue component as a reusable 3rd-party component, avoid using this syntax.**
115+
However, note this makes your Vue component webpack-specific and not compatible with Browserify and [vueify](https://github.com/vuejs/vueify). **If you intend to ship your Vue component as a reusable 3rd-party component, avoid using this syntax.**

Diff for: docs/en/features/es2015.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ You can also customize the features supported in templates using the [`buble` op
5858

5959
### Transpiling Normal `.js` Files
6060

61-
Since `vue-loader` only processes `*.vue` files, you'd need to tell Webpack to process normal `*.js` files with `babel-loader` or `buble-loader` in the Webpack config file. The project scaffolded with `vue-cli` already does it for you.
61+
Since `vue-loader` only processes `*.vue` files, you'd need to tell webpack to process normal `*.js` files with `babel-loader` or `buble-loader` in the webpack config file. The project scaffolded with `vue-cli` already does it for you.
6262

6363
### Configuring Babel with `.babelrc`
6464

Diff for: docs/en/features/hot-reload.md

+24
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,27 @@ When scaffolding the project with `vue-cli`, Hot Reload is enabled out-of-the-bo
1919
When manually setting up your project, hot-reload is enabled automatically when you serve your project with `webpack-dev-server --hot`.
2020

2121
Advanced users may want to check out [vue-hot-reload-api](https://github.com/vuejs/vue-hot-reload-api), which is used internally by `vue-loader`.
22+
23+
## Disabling Hot Reload
24+
25+
Hot Reload is always enabled except following situations:
26+
27+
* webpack `target` is `node` (SSR)
28+
* webpack minifies the code
29+
* `process.env.NODE_ENV === 'production'`
30+
31+
You may use `hotReload: false` option to disable the Hot Reload explicitly:
32+
33+
``` js
34+
module: {
35+
rules: [
36+
{
37+
test: /\.vue$/,
38+
loader: 'vue-loader',
39+
options: {
40+
hotReload: false // disables Hot Reload
41+
}
42+
}
43+
]
44+
}
45+
```

Diff for: docs/en/features/postcss.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Using a config file allows you to share the same config between your normal CSS
1616

1717
Alternatively, you can specify postcss config specifically for `*.vue` files using the `postcss` option for `vue-loader`.
1818

19-
Example usage in Webpack 1.x:
19+
Example usage in webpack 1.x:
2020

2121
``` js
2222
// webpack.config.js
@@ -29,19 +29,19 @@ module.exports = {
2929
}
3030
```
3131

32-
For Webpack 2.x:
32+
For webpack 2.x:
3333

3434
``` js
3535
// webpack.config.js
3636
module.exports = {
3737
// other options...
3838
module: {
39-
// module.rules is the same as module.loaders in 1.x
39+
// `module.rules` is the same as `module.loaders` in 1.x
4040
rules: [
4141
{
4242
test: /\.vue$/,
4343
loader: 'vue-loader',
44-
// vue-loader options goes here
44+
// `vue-loader` options goes here
4545
options: {
4646
// ...
4747
postcss: [require('postcss-cssnext')()]
@@ -62,7 +62,7 @@ In addition to providing an Array of plugins, the `postcss` option also accepts:
6262
postcss: {
6363
plugins: [...], // list of plugins
6464
options: {
65-
parser: sugarss // use sugarss parser
65+
parser: 'sugarss' // use sugarss parser
6666
}
6767
}
6868
```

Diff for: docs/en/options.md

+20-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Options Reference
22

3-
## Usage Difference Between Webpack 1 & 2
3+
## Usage Difference Between webpack 1 & 2
44

5-
For Webpack 2: pass the options directly to the loader rule.
5+
For webpack 2: pass the options directly to the loader rule.
66

77
``` js
88
module.exports = {
@@ -13,21 +13,21 @@ module.exports = {
1313
test: /\.vue$/,
1414
loader: 'vue-loader',
1515
options: {
16-
// vue-loader options
16+
// `vue-loader` options
1717
}
1818
}
1919
]
2020
}
2121
}
2222
```
2323

24-
For Webpack 1.x: add a root `vue` block in your Webpack config.
24+
For webpack 1.x: add a root `vue` block in your webpack config.
2525

2626
``` js
2727
module.exports = {
2828
// ...
2929
vue: {
30-
// vue-loader options
30+
// `vue-loader` options
3131
}
3232
}
3333
```
@@ -36,7 +36,7 @@ module.exports = {
3636

3737
- type: `{ [lang: string]: string }`
3838

39-
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:
39+
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:
4040

4141
- `<template>`: `html`
4242
- `<script>`: `js`
@@ -45,7 +45,7 @@ module.exports = {
4545
For example, to use `babel-loader` and `eslint-loader` to process all `<script>` blocks:
4646

4747
``` js
48-
// Webpack 2.x config
48+
// webpack 2.x config
4949
module: {
5050
rules: [
5151
{
@@ -144,7 +144,7 @@ module.exports = {
144144

145145
Whether to enable source maps for CSS. Disabling this can avoid some relative path related bugs in `css-loader` and make the build a bit faster.
146146

147-
Note this is automatically set to `false` if the `devtool` option is not present in the main Webpack config.
147+
Note this is automatically set to `false` if the `devtool` option is not present in the main webpack config.
148148

149149
### esModule
150150

@@ -183,7 +183,7 @@ module.exports = {
183183
- type: `{ [tag: string]: string | Array<string> }`
184184
- default: `{ img: 'src', image: 'xlink:href' }`
185185

186-
During template compilation, the compiler can transform certain attributes, such as `src` URLs, into `require` calls, so that the target asset can be handled by Webpack. The default config transforms the `src` attribute on `<img>` tags and `xlink:href` attribute on `<image>` tags of SVG.
186+
During template compilation, the compiler can transform certain attributes, such as `src` URLs, into `require` calls, so that the target asset can be handled by webpack. The default config transforms the `src` attribute on `<img>` tags and `xlink:href` attribute on `<image>` tags of SVG.
187187

188188
### buble
189189

@@ -310,3 +310,14 @@ Enable Vue 2.4 SSR compilation optimization that compiles part of the vdom trees
310310
- default: `true` in development mode, `false` in production mode.
311311

312312
Whether generate source maps with cache busting by appending a hash query to the file name. Turning this off can help with source map debugging.
313+
314+
### hotReload
315+
316+
> New in 13.5.0
317+
318+
- type: `boolean`
319+
- default: `true` in development mode, `false` in production mode or when the webpack config has `target: 'node'`.
320+
- allowed value: `false` (`true` will not force Hot Reload neither in production mode nor when `target: 'node'`)
321+
322+
Whether to use webpack [Hot Module Replacement](https://webpack.js.org/concepts/hot-module-replacement/) to apply changes in the browser **without reloading the page**.
323+
Use this option (value `false`) to disable the Hot Reload feature in development mode.

0 commit comments

Comments
 (0)