This repository has been archived by the owner on Nov 17, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 181
/
prod.config.js
70 lines (57 loc) · 1.89 KB
/
prod.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
// 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 strip = require("strip-loader");
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: /\.(jpe?g|png|gif|svg)$/, loader: "file" },
{ test: /\.js$/, exclude: /node_modules/, loaders: [strip.loader("debug"), "babel"] },
{ 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({
transform: function (data) {
return {
main: data.assetsByChunkName.main[0],
css: data.assetsByChunkName.main[1]
};
}
})
]
};