MOBILE-3876 build: Configure bundle minification

main
Noel De Martin 2021-09-23 17:19:09 +02:00
parent a89140df96
commit 3db470c0a4
4 changed files with 430 additions and 31051 deletions

View File

@ -12,8 +12,11 @@
"schematics": {}, "schematics": {},
"architect": { "architect": {
"build": { "build": {
"builder": "@angular-devkit/build-angular:browser", "builder": "@angular-builders/custom-webpack:browser",
"options": { "options": {
"customWebpackConfig": {
"path": "./webpack.config.js"
},
"allowedCommonJsDependencies":[ "allowedCommonJsDependencies":[
"chart.js" "chart.js"
], ],

31437
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -128,6 +128,8 @@
"zone.js": "~0.10.3" "zone.js": "~0.10.3"
}, },
"devDependencies": { "devDependencies": {
"@angular-builders/custom-webpack": "^10.0.1",
"@angular-devkit/architect": "^0.1202.7",
"@angular-devkit/build-angular": "~0.1000.8", "@angular-devkit/build-angular": "~0.1000.8",
"@angular-eslint/builder": "^4.2.0", "@angular-eslint/builder": "^4.2.0",
"@angular-eslint/eslint-plugin": "^4.2.0", "@angular-eslint/eslint-plugin": "^4.2.0",
@ -169,6 +171,7 @@
"jest-preset-angular": "^8.3.1", "jest-preset-angular": "^8.3.1",
"jsonc-parser": "^2.3.1", "jsonc-parser": "^2.3.1",
"native-run": "^1.4.0", "native-run": "^1.4.0",
"terser-webpack-plugin": "^4.2.3",
"ts-jest": "^26.4.1", "ts-jest": "^26.4.1",
"ts-node": "~8.3.0", "ts-node": "~8.3.0",
"typescript": "^3.9.9" "typescript": "^3.9.9"

36
webpack.config.js 100644
View File

@ -0,0 +1,36 @@
// (C) Copyright 2015 Moodle Pty Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
const TerserPlugin = require('terser-webpack-plugin');
module.exports = config => {
config.optimization.minimizer.push(
new TerserPlugin({
terserOptions: {
mangle: {
keep_classnames: true,
keep_fnames: true,
},
compress: {
toplevel: true,
pure_getters: true,
},
keep_classnames: true,
keep_fnames: true,
},
}),
);
return config;
};