Skip to content

Commit 616ac6f

Browse files
committed
update
1 parent bd9ec8c commit 616ac6f

File tree

15 files changed

+107
-21
lines changed

15 files changed

+107
-21
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ React技术栈系列教程,涉及React、Redux、Babel、Webpack等相关技
5656
1. JSX语法
5757
2. React组件
5858
3. React组件状态与生命周期
59-
4. React组件事件
60-
5. React组件ref
59+
4. React组件事件和ref
60+
5. 在React中使用CSS Module
6161

6262
- Redux
6363
1. Redux使用基础
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-

1+
# CommonsChunkPlugin
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
var path = require("path");
2+
3+
var webpack = require("webpack");
4+
5+
module.exports = {
6+
entry: {
7+
utility1: "./src/utility1",
8+
utility2: "./src/utility2",
9+
utility3: "./src/utility3"
10+
},
11+
12+
output: {
13+
path: path.join(__dirname, "buildOutput"),
14+
filename: "[name].js"
15+
},
16+
17+
plugins: [
18+
new webpack.optimize.CommonsChunkPlugin({
19+
// init.js用于存储webpack runtime的代码以及被所有entry都是用的公共模块,本例中init.js = webpack runtime
20+
name: "init"
21+
})
22+
]
23+
};
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
var path = require("path");
2+
3+
var webpack = require("webpack");
4+
5+
module.exports = {
6+
entry: {
7+
pageA: "./src/pageA",
8+
pageB: "./src/pageB"
9+
},
10+
11+
output: {
12+
path: path.join(__dirname, "buildOutput"),
13+
filename: "[name].js"
14+
},
15+
16+
// plugins: [
17+
// new webpack.optimize.CommonsChunkPlugin({
18+
// //本例中init.js = webpack runtime + polyfill + utility2
19+
// name: "init"
20+
// })
21+
// ]
22+
23+
plugins: [
24+
new webpack.optimize.CommonsChunkPlugin({
25+
//本例中init.js = webpack runtime
26+
name: "init",
27+
minChunks: Infinity
28+
})
29+
]
30+
};

tutorials/webpack-common-chunk/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
"clear": "rimraf buildOutput",
88
"prebuild": "npm run clear",
99
"build": "webpack",
10-
"start": "npm run build"
10+
"start": "npm run build",
11+
"example1": "rimraf buildOutput && webpack --config example1.config.js",
12+
"example2": "rimraf buildOutput && webpack --config example2.config.js"
1113
},
1214
"author": "",
1315
"license": "ISC",
@@ -17,7 +19,8 @@
1719
"webpack": "^1.13.3"
1820
},
1921
"reference": [
20-
"https://webpack.github.io/docs/list-of-plugins.html#commonschunkplugin"
22+
"https://webpack.github.io/docs/list-of-plugins.html#commonschunkplugin",
23+
"http://stackoverflow.com/questions/39548175/can-someone-explain-webpacks-commonschunkplugin",
2124
"https://webpack.js.org/plugins/commons-chunk-plugin/",
2225
"https://github.com/webpack/webpack/tree/master/examples/common-chunk-and-vendor-chunk",
2326
"https://github.com/webpack/webpack/tree/master/examples/multiple-entry-points-commons-chunk-css-bundle",

tutorials/webpack-common-chunk/pageA.js renamed to tutorials/webpack-common-chunk/src/pageA.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
var polyfill = require('./polyfill');
12
var utility1 = require('./utility1');
23
var utility2 = require('./utility2');
34

tutorials/webpack-common-chunk/pageB.js renamed to tutorials/webpack-common-chunk/src/pageB.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
var polyfill = require('./polyfill');
12
var utility2 = require('./utility2');
23
var utility3 = require('./utility3');
34

tutorials/webpack-common-chunk/pageC.js renamed to tutorials/webpack-common-chunk/src/pageC.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
var polyfill = require('./polyfill');
12
var utility2 = require('./utility2');
23
var utility3 = require('./utility3');
34

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = "polyfill";

0 commit comments

Comments
 (0)