-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathangular.webpack.js
56 lines (50 loc) · 1.69 KB
/
angular.webpack.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
/**
* Custom angular webpack configuration
*/
const path = require('path');
const CopyPlugin = require("copy-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
module.exports = (config, options) => {
//check for serve
if (config.devServer) {
config.plugins.push(new CopyPlugin({
patterns: [{
context: path.resolve(__dirname, "preview-data", "translation"),
from: "**/*",
to: "assets/translation/"
}]
}))
}
if (config.optimization.minimizer[0]) {
config.optimization.minimizer[0] = (
new TerserPlugin({
terserOptions: {
keep_classnames: true,
keep_fnames: true,
compress: {
global_defs: {
ngDevMode: false,
ngI18nClosureMode: false,
ngJitMode: false
},
pure_getters: false
}
}
})
)
}
config.target = 'electron-renderer';
if (options.fileReplacements) {
for(let fileReplacement of options.fileReplacements) {
if (fileReplacement.replace !== 'src/environments/environment.ts') {
continue;
}
let fileReplacementParts = fileReplacement['with'].split('.');
if (fileReplacementParts.length > 1 && ['web'].indexOf(fileReplacementParts[1]) >= 0) {
config.target = 'web';
}
break;
}
}
return config;
}