This repository has been archived by the owner on Nov 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack_aot_config.js
91 lines (73 loc) · 2.36 KB
/
webpack_aot_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
// PROD WEBPACK ENVIRONMENT
var path = require('path');
var webpack = require('webpack');
var webpackMerge = require('webpack-merge');
const commonWebpackConfig = require('./webpack_common_config.js');
var CompressionPlugin = require("compression-webpack-plugin");
var OptimizeJsPlugin = require('optimize-js-plugin');
var AngularCompilerPlugin = require("@ngtools/webpack").AngularCompilerPlugin;
const ENV = process.env.NODE_ENV = process.env.ENV = 'production';
module.exports = function (env) {
return webpackMerge(commonWebpackConfig(), {
mode: 'production',
entry: {
polyfills: './polyfills.ts',
app: './main-aot.ts'
},
optimization: {
runtimeChunk: {
name: "manifest"
},
splitChunks: {
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: "vendors",
priority: -20,
chunks: "all"
}
}
}
},
module: {
rules: [
{
test: /\.tsx$/,
loader: "@ngtools/webpack"
}
]
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
'ENV': JSON.stringify(ENV)
}
}),
new AngularCompilerPlugin({
tsConfigPath: './tsconfig-aot.json',
entryModule: root('application/app.module#AppModule')
}),
new webpack.LoaderOptionsPlugin({
minimize: true,
debug: false
}),
/** Webpack plugin to optimize javascript file for faster initial load
* by wrapping eagerly-invoked functions
*/
new OptimizeJsPlugin({
sourceMap: false
}),
new webpack.optimize.AggressiveMergingPlugin(),
new CompressionPlugin({
asset: "[path].gz[query]",
algorithm: "gzip",
test: /\.js$|\.css$|\.html$/,
threshold: 10240,
minRatio: 0.8
})
]
})
}
function root(__path) {
return path.join(__dirname, __path);
}