-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.prod.ts
67 lines (61 loc) · 1.75 KB
/
webpack.prod.ts
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
import * as BabelPlugin from 'babel-webpack-plugin';
import * as CleanWebpackPlugin from 'clean-webpack-plugin';
import * as ExtractTextPlugin from 'extract-text-webpack-plugin';
import * as HtmlWebpackPlugin from 'html-webpack-plugin';
import * as CompressionPlugin from 'compression-webpack-plugin';
import * as merge from 'webpack-merge';
import {DefinePlugin, optimize} from 'webpack';
import {baseConfig} from './webpack.base';
module.exports = merge(baseConfig, {
devtool: 'cheap-module-source-map',
entry: [
'babel-polyfill',
'./app/index'
],
output: {
publicPath: './',
filename: 'bundle-[chunkhash].js'
},
module: {
rules: [
{
test: /\.global\.css$/,
loader: ExtractTextPlugin.extract({fallback: 'style-loader', use: 'css-loader'})
},
{
test: /^((?!\.global).)*\.css$/,
loader: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader?modules&importLoaders=1&localIdentName=[local]'
})
}
]
},
plugins: [
new optimize.OccurrenceOrderPlugin(),
new CleanWebpackPlugin(['dist'], {}),
new DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
}),
new BabelPlugin({
test: /\.js$/,
presets: ['es2015', 'stage-0'],
sourceMaps: false,
compact: false
}),
new optimize.ModuleConcatenationPlugin(),
new optimize.UglifyJsPlugin({
compressor: {
screw_ie8: true,
warnings: false
}
}),
new ExtractTextPlugin({filename: 'style-[contenthash].css', allChunks: true}),
new HtmlWebpackPlugin({template: 'index.ejs'}),
new CompressionPlugin({
algorithm: 'gzip',
test: /\.js$|\.html$/,
minRatio: 0.8
})
]
});