-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.production.config.js
72 lines (59 loc) · 1.97 KB
/
webpack.production.config.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
// Webpack config for creating the production bundle.
var path = require("path");
var webpack = require("webpack");
var StatsWriterPlugin = require("webpack-stats-plugin").StatsWriterPlugin;
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var dist = path.resolve(__dirname, "../static/dist");
module.exports = {
devtool: "source-map",
entry: "./src/client.js",
output: {
path: dist,
filename: "[name]-[hash].js",
chunkFilename: "[name]-[chunkhash].js",
publicPath: "/dist/"
},
module: {
loaders: [
{ test: /\.js$/, exclude: /node_modules/, loaders: ["babel"] },
{ test: /\.jpe?g$|\.svg$|\.gif$|\.png$|\.svg$|\.eot$|\.woff$|\.ttf$|\.wav$|\.mp3$/, loader: "file" },
{ test: /\.scss$/, loader: ExtractTextPlugin.extract("style", "css!autoprefixer?browsers=last 2 version!sass") }
]
},
plugins: [
// css files from the extract-text-plugin loader
new ExtractTextPlugin("[name]-[chunkhash].css"),
// ignore dev config
new webpack.IgnorePlugin(/\.\/dev/, /\/config$/),
// set global vars
new webpack.DefinePlugin({
"process.env": {
// Mainly used to require CSS files with webpack, which can happen only on browser
// Used as `if (process.env.BROWSER)...`
BROWSER: JSON.stringify(true),
// Useful to reduce the size of client-side libraries, e.g. react
NODE_ENV: JSON.stringify("production")
}
}),
// optimizations
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
// Write out stats.json file to build directory.
new StatsWriterPlugin({
filename: "stats.json",
fields: null,
transform: function(data) {
var output = {
main: data.assetsByChunkName.main[0],
css: data.assetsByChunkName.main[1]
}
return JSON.stringify(output);
}
})
]
};