Skip to content

[zh-cn] synced from #5e549cb to #cda4973 #1053

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 27, 2017
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions docs/zh-cn/features/hot-reload.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,27 @@
当手动设置你的工程时,热重载会在你启动 `webpack-dev-server --hot` 服务时自动开启。

高阶用户可能希望移步 `vue-loader` 内部使用的 [vue-hot-reload-api](https://github.com/vuejs/vue-hot-reload-api) 继续查阅。

## 关闭热重载

除非下列情况,热重载总是开启的:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里可以稍微调整下(把“除非”移到后面):“热重载默认是开启的,除非遇到以下情况:”


* webpack 的 `target` 的值是 `node` (服务端渲染)
* webpack 会压缩代码
* `process.env.NODE_ENV === 'production'`

你可以设置 `hotReload: false` 选项来显式关闭热重载:

``` js
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
hotReload: false // 关闭热重载
}
}
]
}
```
12 changes: 6 additions & 6 deletions docs/zh-cn/features/postcss.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ Webpack 1.x 例子:
``` js
// webpack.config.js
module.exports = {
// other configs...
// 其它配置……
vue: {
// use custom postcss plugins
// 使用自定义 postcss 插件
postcss: [require('postcss-cssnext')()]
}
}
Expand All @@ -36,12 +36,12 @@ Webpack 2.x 例子:
module.exports = {
// other options...
module: {
// `module.rules` is the same as `module.loaders` in 1.x
// `module.rules` 和 1.x 里的 `module.loaders` 相同
rules: [
{
test: /\.vue$/,
loader: 'vue-loader',
// `vue-loader` options goes here
// `vue-loader` 选项放这里
options: {
// ...
postcss: [require('postcss-cssnext')()]
Expand All @@ -60,9 +60,9 @@ module.exports = {

``` js
postcss: {
plugins: [...], // list of plugins
plugins: [...], // 插件列表
options: {
parser: sugarss // use sugarss parser
parser: 'sugarss' // 使用 sugarss 解析器
}
}
```
11 changes: 11 additions & 0 deletions docs/zh-cn/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,3 +306,14 @@ module.exports = {
- 默认值:在开发环境下是 `true`,在生产环境下是 `false`。

是否通过给文件名后加哈希查询值来避免生成的 source map 被缓存。关掉这一选项有益于 source map 调试。

### hotReload

> 13.5.0 新增

- 类型: `boolean`
- 默认值: 在开发环境下是 `true`,在生产环境下或 webpack 配置中有 `target: 'node'` 的时候是 `false`。
- 允许的值: `false` (`true` 会强制热重载,即便是生产环境或 `target: 'node'` 时)

是否使用 webpack 的[模块热替换](https://webpack.js.org/concepts/hot-module-replacement/)在浏览器中应用变更而**不重载整个页面**。
用这个选项 (值设为 `false`) 在开发环境下关闭热重载特性。