Skip to content

Commit 33d9542

Browse files
committed
updated plugin calls to options object
1 parent 5879483 commit 33d9542

File tree

5 files changed

+49
-15
lines changed

5 files changed

+49
-15
lines changed

examples/move-to-parent/webpack.config.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,26 @@ module.exports = {
1414
},
1515
plugins: [
1616
// check for common modules in children of pageA and move them to the parent
17-
new CommonsChunkPlugin("pageA", null, false),
18-
17+
new CommonsChunkPlugin({
18+
name: "pageA",
19+
children: true
20+
}),
21+
1922
// the same for pageB but move them if at least 3 children share the module
20-
new CommonsChunkPlugin("pageB", null, false, 3),
21-
23+
new CommonsChunkPlugin({
24+
name: "pageB",
25+
children: true,
26+
minChunks: 3
27+
}),
28+
2229
// the same for pageC and pageD but with a custom logic for moving
23-
new CommonsChunkPlugin(["pageC", "pageD"], null, false, function(module, count) {
24-
// move only module "b"
25-
return /b\.js$/.test(module.identifier());
30+
new CommonsChunkPlugin({
31+
names: ["pageC", "pageD"],
32+
children: true,
33+
minChunks: function(module, count) {
34+
// move only module "b"
35+
return /b\.js$/.test(module.identifier());
36+
}
2637
})
2738
]
2839
}

examples/multiple-commons-chunks/webpack.config.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,18 @@ module.exports = {
1414
filename: "[name].js"
1515
},
1616
plugins: [
17-
new CommonsChunkPlugin("admin-commons.js", ["adminPageA", "adminPageB"]),
18-
new CommonsChunkPlugin("commons.js", ["pageA", "pageB", "admin-commons.js"], 2),
19-
new CommonsChunkPlugin("c-commons.js", ["pageC", "adminPageC"]),
17+
new CommonsChunkPlugin({
18+
name: "admin-commons.js",
19+
chunks: ["adminPageA", "adminPageB"]
20+
}),
21+
new CommonsChunkPlugin({
22+
name: "commons.js",
23+
chunks: ["pageA", "pageB", "admin-commons.js"],
24+
minChunks: 2
25+
}),
26+
new CommonsChunkPlugin({
27+
name: "c-commons.js",
28+
chunks: ["pageC", "adminPageC"]
29+
}),
2030
]
21-
}
31+
}

examples/multiple-entry-points-commons-chunk-css-bundle/webpack.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ module.exports = {
2121
]
2222
},
2323
plugins: [
24-
new CommonsChunkPlugin("commons", "commons.js", ["A", "B"]),
24+
new CommonsChunkPlugin({
25+
name: "commons",
26+
filename: "commons.js",
27+
chunks: ["A", "B"]
28+
}),
2529
new ExtractTextPlugin("[name].css"),
2630
]
2731
};

test/Errors.test.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,16 @@ describe("Errors", function() {
101101
filename: "[name].js"
102102
},
103103
plugins: [
104-
new webpack.optimize.CommonsChunkPlugin("a", "a.js", Infinity),
105-
new webpack.optimize.CommonsChunkPlugin("b", "b.js", Infinity)
104+
new webpack.optimize.CommonsChunkPlugin({
105+
name: "a",
106+
filename: "a.js",
107+
minChunks: Infinity
108+
}),
109+
new webpack.optimize.CommonsChunkPlugin({
110+
name: "b",
111+
filename: "b.js",
112+
minChunks: Infinity
113+
})
106114
]
107115
}, function(errors, warnings) {
108116
errors.length.should.be.eql(1);

test/configCases/plugins/banner-plugin/webpack.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ module.exports = {
1212
filename: "[name].js"
1313
},
1414
plugins: [
15-
new webpack.BannerPlugin("A test value", {
15+
new webpack.BannerPlugin({
16+
banner: "A test value",
1617
exclude: ["vendors.js"]
1718
})
1819
]

0 commit comments

Comments
 (0)