-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
79 lines (78 loc) · 2.97 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
module.exports = function (env) {
let config = {
entry: {app: "./src/main.ts", polyfills: "./src/polyfills.ts"},
devtool: 'source-map',
output: {
path: path.resolve('dist'),
filename: '[name].[hash].js',
chunkFilename: '[id].[hash].chunk.js',
publicPath: '/',
sourceMapFilename: '[name].[chunkhash].bundle.map',
},
resolve: {
extensions: ['.ts', '.js']
},
module: {
rules: [
{
test: /\.ts$/,
exclude: 'node_modules',
use: [{loader: 'awesome-typescript-loader'}, {loader: 'angular2-template-loader'}]
},
{
test: /\.html$/,
loader: 'raw-loader',
exclude: /\.async\.(html|css)$/
},
/* Async loading. */
{
test: /\.async\.(html|css)$/,
loaders: ['file?name=[name].[hash].[ext]', 'extract']
},
{ test: /\.css$/, loader: "style-loader!css-loader" },
{ test: /bootstrap\/js\//, loader: 'imports?jQuery=jquery' },
{ test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/, loader: 'url?limit=10000&mimetype=application/font-woff' },
{ test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: 'url?limit=10000&mimetype=application/octet-stream' },
{ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: 'file' },
{ test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: 'url?limit=10000&mimetype=image/svg+xml' },
]
},
plugins: [
//new webpack.NoEmitOnErrorsPlugin(),
new webpack.optimize.CommonsChunkPlugin({
name: ['app', 'polyfills']
//minChunks: module => /node_modules/.test(module.resource)
}),
new webpack.ContextReplacementPlugin(
// The (\\|\/) piece accounts for path separators in *nix and Windows
/angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/,
path.resolve('src'), // location of your src
{} // a map of your routes
),
new HtmlWebpackPlugin({
template: './src/index.html'
})
],
devServer: {
contentBase: './dist',
stats: 'minimal'
}
};
if (env === 'production') {
new webpack.optimize.UglifyJsPlugin({
beautify: false,
mangle: { screw_ie8: true },
compress: { screw_ie8: true},
mangle: {
keep_fnames: true
},
output:{
comments: false
}
})
}
return config;
}