Skip to content

Commit

Permalink
fix: correct webpackHotMiddleware.Options type error
Browse files Browse the repository at this point in the history
  • Loading branch information
tjx666 committed Apr 13, 2020
1 parent a706e49 commit 8a533a1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion scripts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ compiler.run((error, stats) => {
colors: true,
};

console.log(stats.toString(ENABLE_ANALYZE ? 'minimal' : analyzeStatsOpts));
console.log(stats.toString(ENABLE_ANALYZE ? analyzeStatsOpts : 'minimal'));
});
7 changes: 6 additions & 1 deletion scripts/configs/webpack.common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ const htmlMinifyOptions: HtmlMinifierOptions = {
const commonConfig: Configuration = {
cache: true,
context: PROJECT_ROOT,
entry: ['react-hot-loader/patch', resolve(PROJECT_ROOT, './src/index.tsx')],
entry: [
// reload=true 设置 webpack 无法热更新时刷新整个页面,overlay=true 设置编译出错时在网页中显示出错信息遮罩
'webpack-hot-middleware/client?reload=true&overlay=true',
'react-hot-loader/patch',
resolve(PROJECT_ROOT, './src/index.tsx'),
],
output: {
publicPath: '/',
path: resolve(PROJECT_ROOT, './dist'),
Expand Down
6 changes: 1 addition & 5 deletions scripts/middlewares/webpackMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,9 @@ export default function webpackMiddleware(compiler: Compiler) {
// writeToDisk: true
};

const hotMiddlewareOptions: webpackHotMiddleware.Options = {
const hotMiddlewareOptions: webpackHotMiddleware.MiddlewareOptions = {
// sse 路由
path: HMR_PATH,
// 编译出错会在网页中显示出错信息遮罩
overlay: true,
// webpack 卡住自动刷新页面
reload: true,
};

return [
Expand Down

0 comments on commit 8a533a1

Please sign in to comment.