Skip to content

Commit 59c7c16

Browse files
committed
update example configurations for latest mode changes
1 parent c64fd70 commit 59c7c16

File tree

91 files changed

+343
-224
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+343
-224
lines changed

examples/aggressive-merging/template.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ a big file...
2828

2929
# Info
3030

31-
## Uncompressed
31+
## Unoptimized
3232

3333
```
3434
{{stdout}}
3535
```
3636

37-
## Minimized (uglify-js, no zip)
37+
## Production mode
3838

3939
```
40-
{{min:stdout}}
40+
{{production:stdout}}
4141
```

examples/aggressive-merging/webpack.config.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var path = require("path");
22
var AggressiveMergingPlugin = require("../../lib/optimize/AggressiveMergingPlugin");
33
module.exports = {
4-
mode: "production",
4+
// mode: "development" || "production",
55
entry: {
66
pageA: "./pageA",
77
pageB: "./pageB",
@@ -17,5 +17,8 @@ module.exports = {
1717
minSizeReduce: 1.5,
1818
moveToParents: true
1919
})
20-
]
20+
],
21+
optimization: {
22+
occurrenceOrder: true // To keep filename consistent between different modes (for example building only)
23+
}
2124
};

examples/build-common.js

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,44 @@ const cp = require("child_process");
88
const path = require("path");
99
const tc = require("./template-common");
1010
const fs = require("fs");
11+
const async = require("async");
1112

1213
const extraArgs = "";
1314

14-
const hasConfiguration = fs.existsSync("webpack.config.js");
1515
const targetArgs = global.NO_TARGET_ARGS ? "" : " ./example.js js/output.js ";
1616
const displayReasons = global.NO_REASONS ? "" : " --display-reasons --display-used-exports --display-provided-exports";
17-
const modeArgs = hasConfiguration ? "" : "--mode production";
18-
cp.exec(`node ${path.resolve(__dirname, "../bin/webpack.js")} ${modeArgs} ${displayReasons} --display-chunks --display-max-modules 99999 --display-origins --display-entrypoints --output-public-path "js/" -p ${extraArgs} ${targetArgs}`, function(error, stdout, stderr) {
19-
if(stderr)
20-
console.log(stderr);
21-
if(error !== null)
22-
console.log(error);
23-
let readme;
24-
try {
25-
readme = tc.replaceResults(fs.readFileSync(require("path").join(process.cwd(), "template.md"), "utf-8"), process.cwd(), stdout.replace(/[\r\n]*$/, ""), "min");
26-
} catch(e) {
27-
console.log(stderr);
28-
throw e;
17+
const commonArgs = `--display-chunks --display-max-modules 99999 --display-origins --display-entrypoints --output-public-path "js/" ${extraArgs} ${targetArgs}`;
18+
19+
let readme = fs.readFileSync(require("path").join(process.cwd(), "template.md"), "utf-8");
20+
21+
const doCompileAndReplace = (args, prefix, callback) => {
22+
if(!tc.needResults(readme, prefix)) {
23+
callback();
24+
return;
2925
}
30-
cp.exec(`node ${path.resolve(__dirname, "../bin/webpack.js")} ${modeArgs} ${displayReasons} --display-chunks --display-max-modules 99999 --display-origins --display-entrypoints --output-public-path "js/" --output-pathinfo ${extraArgs} ${targetArgs}`, function(error, stdout, stderr) {
31-
console.log(stdout);
26+
if(fs.existsSync("js"))
27+
for(const file of fs.readdirSync("js"))
28+
fs.unlinkSync(`js/${file}`);
29+
cp.exec(`node ${path.resolve(__dirname, "../bin/webpack.js")} ${args} ${displayReasons} ${commonArgs}`, (error, stdout, stderr) => {
3230
if(stderr)
3331
console.log(stderr);
3432
if(error !== null)
3533
console.log(error);
36-
readme = tc.replaceResults(readme, process.cwd(), stdout.replace(/[\r\n]*$/, ""));
37-
readme = tc.replaceBase(readme);
38-
fs.writeFile("README.md", readme, "utf-8", function() {});
34+
try {
35+
readme = tc.replaceResults(readme, process.cwd(), stdout.replace(/[\r?\n]*$/, ""), prefix);
36+
} catch(e) {
37+
console.log(stderr);
38+
throw e;
39+
}
40+
callback();
3941
});
42+
};
43+
44+
async.series([
45+
callback => doCompileAndReplace("--mode production", "production", callback),
46+
callback => doCompileAndReplace("--mode development --devtool none", "development", callback),
47+
callback => doCompileAndReplace("--mode none --output-pathinfo", "", callback)
48+
], () => {
49+
readme = tc.replaceBase(readme);
50+
fs.writeFile("README.md", readme, "utf-8", function() {});
4051
});

examples/chunkhash/template.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ The configuration required for this is:
3636

3737
<!-- inlined minimized file "manifest.[chunkhash].js" -->
3838
<script>
39-
{{min:js/manifest.chunkhash.js}}
39+
{{production:js/manifest.chunkhash.js}}
4040
</script>
4141

4242
<!-- optional when using the CommonChunkPlugin for vendor modules -->
@@ -62,14 +62,14 @@ The configuration required for this is:
6262

6363
# Info
6464

65-
## Uncompressed
65+
## Unoptimized
6666

6767
```
6868
{{stdout}}
6969
```
7070

71-
## Minimized (uglify-js, no zip)
71+
## Production mode
7272

7373
```
74-
{{min:stdout}}
75-
```
74+
{{production:stdout}}
75+
```

examples/chunkhash/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var path = require("path");
22
var webpack = require("../../");
33
module.exports = {
4-
mode: "production",
4+
// mode: "development || "production",
55
entry: {
66
main: "./example",
77
common: ["./vendor"] // optional

examples/code-splitted-css-bundle/template.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@
3737

3838
# Info
3939

40-
## Uncompressed
40+
## Unoptimized
4141

4242
```
4343
{{stdout}}
4444
```
4545

46-
## Minimized (uglify-js, no zip)
46+
## Production mode
4747

4848
```
49-
{{min:stdout}}
49+
{{production:stdout}}
5050
```

examples/code-splitted-css-bundle/webpack.config.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const LoaderOptionsPlugin = require("../../lib/LoaderOptionsPlugin");
22
const ExtractTextPlugin = require("extract-text-webpack-plugin");
33
module.exports = {
4-
mode: "production",
4+
// mode: "development || "production",
55
module: {
66
rules: [
77
{
@@ -22,5 +22,8 @@ module.exports = {
2222
new LoaderOptionsPlugin({
2323
options: {}
2424
})
25-
]
25+
],
26+
optimization: {
27+
occurrenceOrder: true // To keep filename consistent between different modes (for example building only)
28+
}
2629
};

examples/code-splitted-require.context-amd/template.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818

1919
# Info
2020

21-
## Uncompressed
21+
## Unoptimized
2222

2323
```
2424
{{stdout}}
2525
```
2626

27-
## Minimized (uglify-js, no zip)
27+
## Production mode
2828

2929
```
30-
{{min:stdout}}
30+
{{production:stdout}}
3131
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
optimization: {
3+
occurrenceOrder: true // To keep filename consistent between different modes (for example building only)
4+
}
5+
};

examples/code-splitted-require.context/template.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818

1919
# Info
2020

21-
## Uncompressed
21+
## Unoptimized
2222

2323
```
2424
{{stdout}}
2525
```
2626

27-
## Minimized (uglify-js, no zip)
27+
## Production mode
2828

2929
```
30-
{{min:stdout}}
30+
{{production:stdout}}
3131
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
optimization: {
3+
occurrenceOrder: true // To keep filename consistent between different modes (for example building only)
4+
}
5+
};

examples/code-splitting-bundle-loader/template.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ The bundle loader is used to create a wrapper module for `file.js` that loads th
2929

3030
# Info
3131

32-
## Uncompressed
32+
## Unoptimized
3333

3434
```
3535
{{stdout}}
3636
```
3737

38-
## Minimized (uglify-js, no zip)
38+
## Production mode
3939

4040
```
41-
{{min:stdout}}
41+
{{production:stdout}}
4242
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
optimization: {
3+
occurrenceOrder: true // To keep filename consistent between different modes (for example building only)
4+
}
5+
};

examples/code-splitting-harmony/template.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ Providing dynamic expressions to `import` is possible. The same limits as with d
2222

2323
# Info
2424

25-
## Uncompressed
25+
## Unoptimized
2626

2727
```
2828
{{stdout}}
2929
```
3030

31-
## Minimized (uglify-js, no zip)
31+
## Production mode
3232

3333
```
34-
{{min:stdout}}
34+
{{production:stdout}}
3535
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
optimization: {
3+
occurrenceOrder: true // To keep filename consistent between different modes (for example building only)
4+
}
5+
};

examples/code-splitting-native-import-context-filter/template.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ All templates are of this pattern:
3030

3131
# Info
3232

33-
## Uncompressed
33+
## Unoptimized
3434

3535
```
3636
{{stdout}}
3737
```
3838

39-
## Minimized (uglify-js, no zip)
39+
## Production mode
4040

4141
```
42-
{{min:stdout}}
42+
{{production:stdout}}
4343
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
optimization: {
3+
occurrenceOrder: true // To keep filename consistent between different modes (for example building only)
4+
}
5+
};

examples/code-splitting-native-import-context/template.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ All templates are of this pattern:
2626

2727
# Info
2828

29-
## Uncompressed
29+
## Unoptimized
3030

3131
```
3232
{{stdout}}
3333
```
3434

35-
## Minimized (uglify-js, no zip)
35+
## Production mode
3636

3737
```
38-
{{min:stdout}}
38+
{{production:stdout}}
3939
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
optimization: {
3+
occurrenceOrder: true // To keep filename consistent between different modes (for example building only)
4+
}
5+
};

examples/code-splitting-specify-chunk-name/template.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ All templates are of this pattern:
2626

2727
# Info
2828

29-
## Uncompressed
29+
## Unoptimized
3030

3131
```
3232
{{stdout}}
3333
```
3434

35-
## Minimized (uglify-js, no zip)
35+
## Production mode
3636

3737
```
38-
{{min:stdout}}
38+
{{production:stdout}}
3939
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
optimization: {
3+
occurrenceOrder: true // To keep filename consistent between different modes (for example building only)
4+
}
5+
};

examples/code-splitting/template.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,19 @@ You can see that chunks are loaded via JSONP. The additional chunks are pretty s
4646
Minimized
4747

4848
``` javascript
49-
{{min:js/0.output.js}}
49+
{{production:js/0.output.js}}
5050
```
5151

5252
# Info
5353

54-
## Uncompressed
54+
## Unoptimized
5555

5656
```
5757
{{stdout}}
5858
```
5959

60-
## Minimized (uglify-js, no zip)
60+
## Production mode
6161

6262
```
63-
{{min:stdout}}
63+
{{production:stdout}}
6464
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
optimization: {
3+
occurrenceOrder: true // To keep filename consistent between different modes (for example building only)
4+
}
5+
};

examples/coffee-script/template.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525

2626
# Info
2727

28-
## Uncompressed
28+
## Unoptimized
2929

3030
```
3131
{{stdout}}
3232
```
3333

34-
## Minimized (uglify-js, no zip)
34+
## Production mode
3535

3636
```
37-
{{min:stdout}}
37+
{{production:stdout}}
3838
```

examples/coffee-script/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
2-
mode: "production",
2+
// mode: "development || "production",
33
module: {
44
rules: [
55
{ test: /\.coffee$/, loader: "coffee-loader" }

0 commit comments

Comments
 (0)