Skip to content

Commit 9652973

Browse files
authored
Optimize the production build (#49)
Inspired by react-boilerplate setup
1 parent 29ac0ed commit 9652973

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

config/webpack.config.prod.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ var path = require('path');
1111
var autoprefixer = require('autoprefixer');
1212
var webpack = require('webpack');
1313
var HtmlWebpackPlugin = require('html-webpack-plugin');
14+
var ExtractTextPlugin = require('extract-text-webpack-plugin');
1415

1516
var isInNodeModules = 'node_modules' ===
1617
path.basename(path.resolve(path.join(__dirname, '..', '..')));
@@ -22,7 +23,8 @@ module.exports = {
2223
entry: './src/index.js',
2324
output: {
2425
path: path.resolve(__dirname, relative, 'build'),
25-
filename: '[name].[hash].js',
26+
filename: '[name].[chunkhash].js',
27+
chunkFilename: '[name].[chunkhash].chunk.js',
2628
// TODO: this wouldn't work for e.g. GH Pages.
2729
// Good news: we can infer it from package.json :-)
2830
publicPath: '/'
@@ -49,7 +51,7 @@ module.exports = {
4951
{
5052
test: /\.css$/,
5153
include: path.resolve(__dirname, relative, 'src'),
52-
loader: 'style!css!postcss'
54+
loader: ExtractTextPlugin.extract('style', 'css!postcss')
5355
},
5456
{
5557
test: /\.json$/,
@@ -93,6 +95,7 @@ module.exports = {
9395
}),
9496
new webpack.DefinePlugin({ 'process.env.NODE_ENV': '"production"' }),
9597
new webpack.optimize.OccurrenceOrderPlugin(),
98+
new webpack.optimize.DedupePlugin(),
9699
new webpack.optimize.UglifyJsPlugin({
97100
compressor: {
98101
screw_ie8: true,
@@ -105,6 +108,7 @@ module.exports = {
105108
comments: false,
106109
screw_ie8: true
107110
}
108-
})
111+
}),
112+
new ExtractTextPlugin('[name].[contenthash].css')
109113
]
110114
};

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"eslint-loader": "1.4.1",
4545
"eslint-plugin-import": "1.10.3",
4646
"eslint-plugin-react": "5.2.2",
47+
"extract-text-webpack-plugin": "1.0.1",
4748
"file-loader": "0.9.0",
4849
"html-webpack-plugin": "2.22.0",
4950
"json-loader": "0.5.4",
@@ -77,6 +78,7 @@
7778
"eslint-loader",
7879
"eslint-plugin-import",
7980
"eslint-plugin-react",
81+
"extract-text-webpack-plugin",
8082
"file-loader",
8183
"html-webpack-plugin",
8284
"json-loader",

0 commit comments

Comments
 (0)