Skip to content
This repository was archived by the owner on Mar 14, 2020. It is now read-only.

Commit e750c44

Browse files
committed
Simplify the Webpack config file
1 parent 792bb22 commit e750c44

File tree

2 files changed

+10
-21
lines changed

2 files changed

+10
-21
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
"mini-css-extract-plugin": "0.2.0",
2121
"node-sass": "4.7.2",
2222
"null-loader": "0.1.1",
23-
"optimize-css-assets-webpack-plugin": "4.0.0",
2423
"path": "0.12.7",
2524
"prettier": "1.11.1",
2625
"react": "16.2.0",

webpack.config.babel.js

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,16 @@ import webpack from 'webpack';
22
import path from 'path';
33
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
44
import HtmlWebpackPlugin from 'html-webpack-plugin';
5-
import OptimizeCSSAssetsPlugin from 'optimize-css-assets-webpack-plugin';
65

7-
const vendors = ['react', 'react-dom'];
8-
const isProduction = process.env.NODE_ENV === 'production';
6+
const vendor = ['react', 'react-dom'];
97

108
export default {
119
name: 'client',
12-
mode: isProduction ? 'production' : 'development',
10+
mode: 'production',
1311
target: 'web',
1412
entry: {
1513
bundle: './entry.js',
16-
vendors,
14+
vendor,
1715
},
1816
context: path.join(__dirname, 'src'),
1917

@@ -22,8 +20,6 @@ export default {
2220
children: false,
2321
},
2422

25-
devtool: isProduction ? false : 'inline-cheap-module-eval-source-map',
26-
2723
output: {
2824
path: path.join(__dirname, 'target', 'build'),
2925
filename: '[name].js',
@@ -51,47 +47,41 @@ export default {
5147
optimization: {
5248
splitChunks: {
5349
cacheGroups: {
50+
// Don't generate automatic common chunks
5451
default: false,
52+
// Don't generate automatic vendor chunks
53+
vendors: false,
5554
// Custom common chunk
5655
bundle: {
5756
name: 'commons',
5857
chunks: 'all',
5958
minChunks: 3,
6059
reuseExistingChunk: false,
6160
},
62-
// Customer vendor
63-
vendors: {
61+
// Custom vendor chunk by name
62+
vendor: {
6463
chunks: 'initial',
65-
name: 'vendors',
66-
test: 'vendors',
64+
name: 'vendor',
65+
test: 'vendor',
6766
},
6867
// Merge all the CSS into one file
6968
styles: {
7069
name: 'styles',
7170
test: /\.s?css$/,
7271
chunks: 'all',
7372
minChunks: 1,
74-
reuseExistingChunk: true,
7573
enforce: true,
7674
},
7775
},
7876
},
7977
},
80-
profile: false,
8178

8279
plugins: [
83-
new webpack.optimize.ModuleConcatenationPlugin(),
8480
new MiniCssExtractPlugin({
8581
filename: '[name].css',
8682
chunkFilename: '[name].css',
8783
}),
88-
new OptimizeCSSAssetsPlugin(),
8984
new HtmlWebpackPlugin({
90-
minify: {
91-
collapseWhitespace: true,
92-
preserveLineBreaks: true,
93-
removeComments: true,
94-
},
9585
filename: 'index.html',
9686
template: path.join(__dirname, 'src', 'index.html'),
9787
}),

0 commit comments

Comments
 (0)