Skip to content

Commit 45d462f

Browse files
Jinjiangyyx990803
authored andcommitted
docs: [zh-cn] synced from #5e549cb to #cda4973 (#1053)
* [zh-cn] synced from #5e549cb to #cda4973 * Update hot-reload.md * Update hot-reload.md
1 parent b3edfac commit 45d462f

File tree

3 files changed

+41
-6
lines changed

3 files changed

+41
-6
lines changed

docs/zh-cn/features/hot-reload.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,27 @@
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+
```

docs/zh-cn/features/postcss.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ Webpack 1.x 例子:
2121
``` js
2222
// webpack.config.js
2323
module.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 例子:
3636
module.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
```

docs/zh-cn/options.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff 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`) 在开发环境下关闭热重载特性。

0 commit comments

Comments
 (0)