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 1919当手动设置你的工程时,热重载会在你启动 ` webpack-dev-server --hot ` 服务时自动开启。
2020
2121高阶用户可能希望移步 ` 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 例子:
2121``` js
2222// webpack.config.js
2323module .exports = {
24- // other configs...
24+ // 其它配置……
2525 vue: {
26- // use custom postcss plugins
26+ // 使用自定义 postcss 插件
2727 postcss: [require (' postcss-cssnext' )()]
2828 }
2929}
@@ -36,12 +36,12 @@ Webpack 2.x 例子:
3636module .exports = {
3737 // other options...
3838 module: {
39- // `module.rules` is the same as `module.loaders` in 1.x
39+ // `module.rules` 和 1.x 里的 `module.loaders` 相同
4040 rules: [
4141 {
4242 test: / \. vue$ / ,
4343 loader: ' vue-loader' ,
44- // `vue-loader` options goes here
44+ // `vue-loader` 选项放这里
4545 options: {
4646 // ...
4747 postcss: [require (' postcss-cssnext' )()]
@@ -60,9 +60,9 @@ module.exports = {
6060
6161 ``` js
6262 postcss: {
63- plugins: [... ], // list of plugins
63+ plugins: [... ], // 插件列表
6464 options: {
65- parser: sugarss // use sugarss parser
65+ parser: ' sugarss' // 使用 sugarss 解析器
6666 }
6767 }
6868 ```
Original file line number Diff line number Diff line change @@ -306,3 +306,14 @@ module.exports = {
306306- 默认值:在开发环境下是 ` true` ,在生产环境下是 ` false` 。
307307
308308是否通过给文件名后加哈希查询值来避免生成的 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