mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-14 18:12:09 +08:00
fix(webpack): angular 16 build with terser (#10302)
This commit is contained in:
@ -318,7 +318,10 @@ exports[`angular configuration for android 1`] = `
|
||||
keep_infinity: true,
|
||||
drop_console: false,
|
||||
global_defs: {
|
||||
__UGLIFIED__: true
|
||||
__UGLIFIED__: true,
|
||||
ngDevMode: false,
|
||||
ngI18nClosureMode: false,
|
||||
ngJitMode: false
|
||||
}
|
||||
},
|
||||
keep_fnames: true,
|
||||
@ -741,7 +744,10 @@ exports[`angular configuration for ios 1`] = `
|
||||
keep_infinity: true,
|
||||
drop_console: false,
|
||||
global_defs: {
|
||||
__UGLIFIED__: true
|
||||
__UGLIFIED__: true,
|
||||
ngDevMode: false,
|
||||
ngI18nClosureMode: false,
|
||||
ngJitMode: false
|
||||
}
|
||||
},
|
||||
keep_fnames: true,
|
||||
|
@ -13,6 +13,16 @@ import {
|
||||
getPlatformName,
|
||||
} from '../helpers/platform';
|
||||
import base from './base';
|
||||
// until we can switch to async/await on the webpack config, copy this from '@angular/compiler-cli'
|
||||
const GLOBAL_DEFS_FOR_TERSER = {
|
||||
ngDevMode: false,
|
||||
ngI18nClosureMode: false,
|
||||
};
|
||||
|
||||
const GLOBAL_DEFS_FOR_TERSER_WITH_AOT = {
|
||||
...GLOBAL_DEFS_FOR_TERSER,
|
||||
ngJitMode: false,
|
||||
};
|
||||
|
||||
export default function (config: Config, env: IWebpackEnv = _env): Config {
|
||||
base(config, env);
|
||||
@ -269,6 +279,19 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
|
||||
])
|
||||
);
|
||||
|
||||
config.optimization.minimizer('TerserPlugin').tap((args) => {
|
||||
args[0].terserOptions ??= {};
|
||||
args[0].terserOptions.compress ??= {};
|
||||
args[0].terserOptions.compress.global_defs ??= {};
|
||||
args[0].terserOptions.compress.global_defs = {
|
||||
...args[0].terserOptions.compress.global_defs,
|
||||
...(disableAOT
|
||||
? GLOBAL_DEFS_FOR_TERSER
|
||||
: GLOBAL_DEFS_FOR_TERSER_WITH_AOT),
|
||||
};
|
||||
return args;
|
||||
});
|
||||
|
||||
// todo: re-visit later, disabling by default now
|
||||
// config.plugin('DefinePlugin').tap((args) => {
|
||||
// args[0] = merge(args[0], {
|
||||
|
Reference in New Issue
Block a user