-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.prod.config.js
55 lines (52 loc) · 1.85 KB
/
webpack.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
const path = require('path');
// Webpack and its plugins
const CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin');
const CompressionPlugin = require('compression-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const DedupePlugin = require('webpack/lib/optimize/DedupePlugin');
const DefinePlugin = require('webpack/lib/DefinePlugin');
const OccurrenceOrderPlugin = require('webpack/lib/optimize/OccurrenceOrderPlugin');
const UglifyJsPlugin = require('webpack/lib/optimize/UglifyJsPlugin');
const ENV = process.env.NODE_ENV = 'production';
const metadata = {
env: ENV
};
module.exports = {
debug: false,
devtool: 'source-map',
entry: {
'main' : './src/main.ts',
'vendor': './src/vendor.ts'
},
metadata: metadata,
module: {
loaders: [
{test: /\.css$/, loader: 'to-string!css', exclude: /node_modules/}, // Inline CSS into components
{test: /\.css$/, loader: 'style!css', exclude: /src/}, // Add CSS as style tag to index.html
{test: /\.html$/, loader: 'html?caseSensitive=true'},
{test: /\.ts$/, loaders: [
{loader: 'ts', query: {compilerOptions: {noEmit: false}}},
{loader: 'angular2-template'}
]}
]
},
output: {
path : './dist',
filename: 'bundle.js'
},
plugins: [
new CommonsChunkPlugin({name: 'vendor', filename: 'vendor.bundle.js', minChunks: Infinity}),
new CompressionPlugin({regExp: /\.css$|\.html$|\.js$|\.map$/}),
new CopyWebpackPlugin([{from: './src/index.html', to: 'index.html'}]),
new DedupePlugin(),
new DefinePlugin({'webpack': {'ENV': JSON.stringify(metadata.env)}}),
new OccurrenceOrderPlugin(true),
new UglifyJsPlugin({
compress: {screw_ie8 : true},
mangle: {screw_ie8 : true}
})
],
resolve: {
extensions: ['', '.ts', '.js']
}
};