File tree Expand file tree Collapse file tree 3 files changed +41
-6
lines changed Expand file tree Collapse file tree 3 files changed +41
-6
lines changed Original file line number Diff line number Diff line change 19
19
当手动设置你的工程时,热重载会在你启动 ` webpack-dev-server --hot ` 服务时自动开启。
20
20
21
21
高阶用户可能希望移步 ` vue-loader ` 内部使用的 [ vue-hot-reload-api] ( https://github.com/vuejs/vue-hot-reload-api ) 继续查阅。
22
+
23
+ ## 关闭热重载
24
+
25
+ 热重载默认是开启的,除非遇到以下情况:
26
+
27
+ * webpack 的 ` target ` 的值是 ` node ` (服务端渲染)
28
+ * webpack 会压缩代码
29
+ * ` process.env.NODE_ENV === 'production' `
30
+
31
+ 你可以设置 ` hotReload: false ` 选项来显式关闭热重载:
32
+
33
+ ``` js
34
+ module: {
35
+ rules: [
36
+ {
37
+ test: / \. vue$ / ,
38
+ loader: ' vue-loader' ,
39
+ options: {
40
+ hotReload: false // 关闭热重载
41
+ }
42
+ }
43
+ ]
44
+ }
45
+ ```
Original file line number Diff line number Diff line change @@ -21,9 +21,9 @@ Webpack 1.x 例子:
21
21
``` js
22
22
// webpack.config.js
23
23
module .exports = {
24
- // other configs...
24
+ // 其它配置……
25
25
vue: {
26
- // use custom postcss plugins
26
+ // 使用自定义 postcss 插件
27
27
postcss: [require (' postcss-cssnext' )()]
28
28
}
29
29
}
@@ -36,12 +36,12 @@ Webpack 2.x 例子:
36
36
module .exports = {
37
37
// other options...
38
38
module: {
39
- // `module.rules` is the same as `module.loaders` in 1.x
39
+ // `module.rules` 和 1.x 里的 `module.loaders` 相同
40
40
rules: [
41
41
{
42
42
test: / \. vue$ / ,
43
43
loader: ' vue-loader' ,
44
- // `vue-loader` options goes here
44
+ // `vue-loader` 选项放这里
45
45
options: {
46
46
// ...
47
47
postcss: [require (' postcss-cssnext' )()]
@@ -60,9 +60,9 @@ module.exports = {
60
60
61
61
``` js
62
62
postcss: {
63
- plugins: [... ], // list of plugins
63
+ plugins: [... ], // 插件列表
64
64
options: {
65
- parser: sugarss // use sugarss parser
65
+ parser: ' sugarss' // 使用 sugarss 解析器
66
66
}
67
67
}
68
68
```
Original file line number Diff line number Diff line change @@ -306,3 +306,14 @@ module.exports = {
306
306
- 默认值:在开发环境下是 ` true` ,在生产环境下是 ` false` 。
307
307
308
308
是否通过给文件名后加哈希查询值来避免生成的 source map 被缓存。关掉这一选项有益于 source map 调试。
309
+
310
+ ### hotReload
311
+
312
+ > 13.5 .0 新增
313
+
314
+ - 类型: ` boolean`
315
+ - 默认值: 在开发环境下是 ` true` ,在生产环境下或 webpack 配置中有 ` target: 'node'` 的时候是 ` false` 。
316
+ - 允许的值: ` false` (` true` 会强制热重载,即便是生产环境或 ` target: 'node'` 时)
317
+
318
+ 是否使用 webpack 的[模块热替换](https: // webpack.js.org/concepts/hot-module-replacement/)在浏览器中应用变更而**不重载整个页面**。
319
+ 用这个选项 (值设为 ` false` ) 在开发环境下关闭热重载特性。
You can’t perform that action at this time.
0 commit comments