-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.prod.config.ts
61 lines (50 loc) · 1.52 KB
/
webpack.prod.config.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
import * as ExtractTextPlugin from 'extract-text-webpack-plugin'
import * as path from 'path'
import * as UglifyJSPlugin from 'uglifyjs-webpack-plugin'
import * as webpack from 'webpack'
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'
import * as webpackMerge from 'webpack-merge'
import { commonConfig, cssLoaders } from './webpack.common'
import { Configuration } from './webpack2.api'
const prod: Configuration = {
output: {
filename: '[name].[chunkhash].js',
chunkFilename: '[name].[chunkhash].js',
path: path.resolve(__dirname, 'dist')
},
module: {
rules: [
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
use: cssLoaders,
fallback: 'style-loader'
})
}
]
},
plugins: [
new BundleAnalyzerPlugin({
analyzerMode: 'disabled', // change it to `server` to view bundle stats
reportFilename: 'report.html',
generateStatsFile: true,
statsFilename: 'stats.json'
}),
new webpack.DefinePlugin({
// do not use an object for 'process.env' otherwise all other environment
// variables are set to 'undefined'
'process.env.NODE_ENV': JSON.stringify('production')
}),
new webpack.LoaderOptionsPlugin({
minimize: true,
debug: false
}),
new UglifyJSPlugin(),
new ExtractTextPlugin('app.[contentHash].css'),
new webpack.optimize.CommonsChunkPlugin({
name: 'app',
filename: 'app-[hash].min.js'
})
]
}
export default webpackMerge(commonConfig, prod)