1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-03 13:33:32 +01:00

Define Angular CLI globals to support tree shaking (#1408)

This commit is contained in:
Oscar Hinton 2022-03-22 10:09:19 +01:00 committed by GitHub
parent 09d7376f39
commit 37e9523f00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,9 @@ const { merge } = require("webpack-merge");
const HtmlWebpackPlugin = require("html-webpack-plugin"); const HtmlWebpackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin"); const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const { AngularWebpackPlugin } = require("@ngtools/webpack"); const { AngularWebpackPlugin } = require("@ngtools/webpack");
const TerserPlugin = require("terser-webpack-plugin");
const NODE_ENV = process.env.NODE_ENV == null ? "development" : process.env.NODE_ENV;
const common = { const common = {
module: { module: {
@ -39,7 +42,7 @@ const common = {
const renderer = { const renderer = {
mode: "production", mode: "production",
devtool: false, devtool: "source-map",
target: "electron-renderer", target: "electron-renderer",
node: { node: {
__dirname: false, __dirname: false,
@ -48,7 +51,19 @@ const renderer = {
"app/main": "./src/app/main.ts", "app/main": "./src/app/main.ts",
}, },
optimization: { optimization: {
minimize: false, minimizer: [
new TerserPlugin({
terserOptions: {
// Replicate Angular CLI behaviour
compress: {
global_defs: {
ngDevMode: false,
ngI18nClosureMode: false,
},
},
},
}),
],
splitChunks: { splitChunks: {
cacheGroups: { cacheGroups: {
commons: { commons: {