-
Notifications
You must be signed in to change notification settings - Fork 29
/
webpack.config.js
65 lines (61 loc) · 1.88 KB
/
webpack.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
56
57
58
59
60
61
62
63
64
65
const webpack = require('webpack');
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const config = {
entry: {
'vendor': './src/vendor',
'app': './src/bootstrap'
},
output: {
path: path.resolve(__dirname, './dist'),
filename: '[name].js'
},
resolve: {
extensions: ['.ts', '.es6', '.js', '.json']
},
module: {
rules: [
{ enforce: 'pre', test: /\.ts$/, exclude: /node_modules/, loader: 'tslint-loader' },
{ test: /\.ts$/, exclude: /node_modules/, loader: 'ts-loader' },
{ test: /\.json$/, loader: 'json-loader' },
{ test: /\.html/, loader: 'html-loader?minimize=false' },
{ test: /\.styl$/, loader: 'css-loader!stylus-loader' },
{ test: /\.css$/, loader: 'style-loader!css-loader' },
{ test: /\.(gif|png|jpe?g)$/i, loader: 'file-loader?name=dist/images/[name].[ext]' },
{ test: /\.woff2?$/, loader: 'url-loader?name=dist/fonts/[name].[ext]&limit=10000&mimetype=application/font-woff' },
{ test: /\.(ttf|eot|svg)$/, loader: 'file-loader?name=dist/fonts/[name].[ext]' }
]
},
plugins: [
// Fixes Angular 2 error
new webpack.ContextReplacementPlugin(
/angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/,
__dirname
)
]
};
if (!(process.env.WEBPACK_ENV === 'production')) {
config.devtool = 'source-map';
config.plugins = config.plugins.concat([
new webpack.DefinePlugin({
'WEBPACK_ENV': '"dev"'
})
])
} else {
config.devtool = 'hidden-source-map';
config.plugins = config.plugins.concat([
new webpack.optimize.UglifyJsPlugin({
compress: {
screw_ie8: true,
warnings: false
},
comments: false,
sourceMap: true
}),
new webpack.DefinePlugin({
'WEBPACK_ENV': '"production"'
}),
new CopyWebpackPlugin([{ from: './src/index.html' }], {})
]);
}
module.exports = config;