-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
95 lines (79 loc) · 2.09 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
'use strict';
var path = require('path');
var webpack = require('webpack');
// -- external webpack plugins
var HtmlWebpackPlugin = require('html-webpack-plugin');
var CompressionPlugin = require('compression-webpack-plugin');
// -- internal webpack plugins
var DefinePlugin = webpack.DefinePlugin;
var UglifyJsPlugin = webpack.optimize.UglifyJsPlugin;
var AggressiveMergingPlugin = webpack.optimize.AggressiveMergingPlugin;
var ContextReplacementPlugin = webpack.ContextReplacementPlugin;
module.exports = {
// define the tool used
// on development to aid debugging
devtool: 'source-map',
// entry point
entry: 'bootstrap.ts',
// output definition
output: {
filename: 'app.[hash].js',
path: path.join(__dirname, 'dist')
},
// plugins
plugins: [
new DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
}),
new HtmlWebpackPlugin({
template: 'src/index.html',
chunksSortMode: 'dependency'
}),
new ContextReplacementPlugin(
/angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/,
path.resolve(__dirname, '.no-dir/')
),
new UglifyJsPlugin({
sourceMap: true,
mangle: { keep_fnames: true }
}),
new AggressiveMergingPlugin(),
new CompressionPlugin({
asset: "[path].gz[query]",
algorithm: "gzip",
test: /\.js$|\.css$|\.html$/,
threshold: 10240, // compress assets > 10KB
minRatio: 0.8 // with 80% compression ratio
})
],
// loaders definitions
module: {
rules: [
// transpiles Typescript
{
test: /\.tsx?$/,
loader: 'ts-loader',
exclude: /node_modules/
},
// process SASS/SCSS files and loads them
{
test: /\.scss$/,
loader: 'sass-loader',
exclude: /node_modules/
},
// loads HTML templates
{
test: /\.html$/,
loader: 'html-loader',
exclude: /node_modules/
}
]
},
// resolvers definitions
resolve: {
extensions: ['.js', '.ts'],
modules: [path.join(__dirname, 'src'), 'node_modules']
}
}