Skip to content

Commit 84b8112

Browse files
author
谢明
committed
feat: 模块加载热更新
1 parent a99ba31 commit 84b8112

File tree

4 files changed

+9
-32
lines changed

4 files changed

+9
-32
lines changed

.babelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"plugins": [
1515
"transform-runtime",
1616
"syntax-dynamic-import",
17+
"react-hot-loader/babel",
1718
"react-loadable/babel",
1819
"transform-decorators-legacy",
1920
["import", { "libraryName": "antd", "libraryDirectory": "es", "style": true }]

config/webpack.config.common.js

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ const isDev = process.env.NODE_ENV !== 'production';
66

77
module.exports = {
88
target: 'web',
9-
entry: ['babel-polyfill', './src/client.js'],
9+
entry: [
10+
'babel-polyfill',
11+
'./src/client.js'
12+
],
1013
output: {
1114
publicPath: '/',
1215
path: resolve(__dirname, '..', 'build'),
@@ -105,39 +108,11 @@ module.exports = {
105108
],
106109
resolve: {
107110
modules: [resolve(__dirname, '../src/'), 'node_modules'],
108-
extensions: [ '.js', '.scss', '.less' ]
111+
extensions: ['.js', '.scss', '.less']
109112
},
110113
optimization: {
111114
splitChunks: {
112-
cacheGroups: {
113-
default: false,
114-
vendors: false,
115-
116-
// vendor chunk
117-
vendor: {
118-
// name of the chunk
119-
name: 'vendor',
120-
121-
// async + async chunks
122-
chunks: 'all',
123-
124-
// import file path containing node_modules
125-
test: /node_modules/,
126-
127-
// priority
128-
priority: 20
129-
},
130-
131-
// common chunk
132-
common: {
133-
name: 'common',
134-
minChunks: 2,
135-
chunks: 'all',
136-
priority: 10,
137-
reuseExistingChunk: true,
138-
enforce: true
139-
}
140-
}
115+
chunks: 'all'
141116
}
142117
},
143118
stats: {

src/components/Article/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22

33
const Article = () => (
4-
<p>2018-09-19T07:52:12.383Z - info: Application env: development
4+
<p>MN2018-09-19T07:52:12.383Z - info: Application env: development
55
2018-09-19T07:52:12.947Z - info: HTTP server is now running on http://localhost:3001
66
webpack built 2400ef2b021b433f8527 in 5849ms
77
2018-09-19T07:52:18.328Z - info: Hash: 2400ef2b021b433f8527

src/containers/AppLayout.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Loadable from 'react-loadable';
33
import { Route, Switch } from 'react-router-dom';
44
import NotFound from '../containers/NotFound';
55
import NavBar from '../components/NavBar';
6+
// import Article from '../components/Article';
67

78
const Home = Loadable({
89
loader: () => import('../components/CssModule' /* webpackChunkName: 'Home' */),

0 commit comments

Comments
 (0)