Skip to content

Commit

Permalink
feat: support disable hmr with env variable HMR=none
Browse files Browse the repository at this point in the history
  • Loading branch information
sorrycc committed Mar 9, 2020
1 parent 0879461 commit b3069fb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
4 changes: 4 additions & 0 deletions docs/docs/env-variables.md
Expand Up @@ -89,6 +89,10 @@ $ FORK_TS_CHECKER=1 umi dev
$ FRIENDLY_ERROR=none umi dev
```

### HMR

设为 `none` 时禁用代码热更新功能。

### HTML

设为 `none` 时不输出 HTML,`umi build` 时有效。
Expand Down
4 changes: 4 additions & 0 deletions docs/docs/env-variables.zh-CN.md
Expand Up @@ -84,6 +84,10 @@ $ FORK_TS_CHECKER=1 umi dev
$ FRIENDLY_ERROR=none umi dev
```

### HMR

设为 `none` 时禁用代码热更新功能。

### HTML

设为 `none` 时不输出 HTML,`umi build` 时有效。
Expand Down
8 changes: 5 additions & 3 deletions packages/bundler-webpack/src/getConfig/getConfig.ts
Expand Up @@ -335,9 +335,11 @@ export default async function getConfig(
webpackConfig.when(
isDev,
webpackConfig => {
webpackConfig
.plugin('hmr')
.use(bundleImplementor.HotModuleReplacementPlugin);
if (hot) {
webpackConfig
.plugin('hmr')
.use(bundleImplementor.HotModuleReplacementPlugin);
}
},
webpackConfig => {
// don't emit files if have error
Expand Down
Expand Up @@ -41,7 +41,7 @@ export async function getBundleAndConfigs({
env,
type,
port,
hot: type === ConfigType.csr,
hot: type === ConfigType.csr && process.env.HMR !== 'none',
entry: {
umi: join(api.paths.absTmpPath!, 'umi.ts'),
},
Expand Down

0 comments on commit b3069fb

Please sign in to comment.