-
Notifications
You must be signed in to change notification settings - Fork 298
/
prod.client.config.babel.js
77 lines (65 loc) · 1.8 KB
/
prod.client.config.babel.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
import path from "path";
import webpack from "webpack";
import AssetsPlugin from "assets-webpack-plugin";
import CleanWebpackPlugin from "clean-webpack-plugin";
import UglifyJSPlugin from "uglifyjs-webpack-plugin";
import CopyWebpackPlugin from "copy-webpack-plugin";
import generateConfig, { srcDir, rootDir, srcPublicDir, distPublicDir } from "./config-generator";
const hash = "[chunkhash]";
const configDirName = "config";
// Config dir is the dir that contains all the configurations
const configDir = path.join(srcDir, configDirName);
// We would need the assets as different file as we
// would like it to include in the dev.server.js
const AssetsPluginInstance = new AssetsPlugin({
filename: "assets.js",
path: configDir,
update: true,
prettyPrint: true,
processOutput: function (assets) {
return `export default ${JSON.stringify(assets)};`;
}
});
const entry = {
// Initial entry point
// @todo Need to replace with routes
"app": path.join(srcDir, "client", "index.js"),
};
const plugins = [
// While building remove the dist dir
new CleanWebpackPlugin(["dist"], {
root: rootDir,
verbose: true,
}),
// Assets plugin to generate
AssetsPluginInstance,
// Uglify the output so that we have the most optimized code
new UglifyJSPlugin({
compress: true,
comments: false,
sourceMap: false,
}),
// Create common chunk of data
new webpack.optimize.CommonsChunkPlugin({
name: "commons",
filename: `${hash}.commons.js`,
minChunks: Infinity,
}),
new CopyWebpackPlugin([
{
from: srcPublicDir,
to: distPublicDir,
}
]),
new webpack.DefinePlugin({
"process.env.NODE_ENV": JSON.stringify("production")
})
];
const devtool = false;
export default generateConfig({
hash,
plugins,
entry,
devtool,
universalCss: true,
});