-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.prod.js
81 lines (75 loc) · 2.15 KB
/
webpack.config.prod.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
const path = require("path");
const webpack = require("webpack");
/**
* @link ./file-changer.js
* file-changer plugin for using move file from anywhere to another place and placeholder some parameters.
* @type {ChangerPlugin|exports|module.exports}
*/
const Changer = require("webpack-file-changer");
/**
* import common webpack settings
*/
const commonSettings = require("./webpack.config.common.js");
/**
* @link https://github.com/webpack/docs/wiki/optimization#deduplication
* @type DedupePlugin
*/
commonSettings.plugins.push(new webpack.optimize.DedupePlugin());
/**
* @link https://github.com/webpack/docs/wiki/optimization#deduplication
* @type DedupePlugin
*/
commonSettings.plugins.push(new webpack.optimize.UglifyJsPlugin());
/**
* @link https://github.com/webpack/docs/wiki/optimization#minimize
* @type OccurenceOrderPlugin
*/
commonSettings.plugins.push(new webpack.optimize.OccurenceOrderPlugin());
/**
* https://github.com/webpack/docs/wiki/optimization#chunks
* @type LimitChunkCountPlugin
*/
commonSettings.plugins.push(new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 15 }));
/**
* @link https://github.com/webpack/docs/wiki/optimization#chunks
* @type MinChunkSizePlugin
*/
commonSettings.plugins.push(new webpack.optimize.MinChunkSizePlugin({ minChunkSize: 10000 }));
/**
*
* @type {{app: *[]}}
*/
commonSettings.entry = {
app: [commonSettings.paths.app]
};
/**
*
* @type {{path: (string|*), filename: string, chunkFilename: string}}
*/
commonSettings.output = {
path: commonSettings.paths.build,
filename: "bundle.[hash].js",
chunkFilename: "[id].[hash].bundle.js"
};
/**
path: commonSettings.paths.build,
filename: "bundle.[hash].js",
chunkFilename: "[id].[hash].bundle.js"
*/
commonSettings.plugins.push(new Changer({
move: [{
from: commonSettings.paths.assets,
to: commonSettings.paths.build
}
],
change: [{
file: path.join(commonSettings.output.path, "index.html"),
parameters: {
"bundle.js": "bundle.[hash].js",
BUILD_TIME: new Date().toString(),
BUILD_NO: new Date().getTime()
}
}
]
}));
module.exports = commonSettings;