enable Angular production mode

Test: npm run build:prod
Change-Id: Iadfe6f81b0cfb611aa6b9266a08424927d82c5d1
This commit is contained in:
Kean Mariotti
2022-07-05 08:37:29 +00:00
parent 6cbe5e5e04
commit 7f1e9e3c45
5 changed files with 32 additions and 21 deletions

View File

@@ -0,0 +1,20 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* 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.
*/
import {platformBrowserDynamic} from "@angular/platform-browser-dynamic";
import {AppModule} from "./app/app.module";
platformBrowserDynamic().bootstrapModule(AppModule)
.catch(err => console.error(err));

View File

@@ -13,23 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {enableProdMode} from "@angular/core";
import {platformBrowserDynamic} from "@angular/platform-browser-dynamic";
import {AppModule} from "./app/app.module";
/*
* For easier debugging in development mode, you can import the following file
* to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
*
* This import should be commented out in production mode because it will have a negative impact
* on performance if an error is thrown.
*/
// import 'zone.js/plugins/zone-error'; // Included with Angular CLI.
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
//TODO: implement production mode switch
//enableProdMode();
enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule)
.catch(err => console.error(err));

View File

@@ -17,11 +17,6 @@ const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: {
polyfills: "./src/polyfills.ts",
app: "./src/main.ts"
},
resolve: {
extensions: [".ts", ".js"],
modules: [

View File

@@ -18,6 +18,10 @@ const configCommon = require('./webpack.config.common');
const configDev = {
mode: 'development',
entry: {
polyfills: "./src/polyfills.ts",
app: "./src/main.dev.ts"
},
devtool: "source-map",
};

View File

@@ -21,6 +21,10 @@ const HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin
const configProd = {
mode: 'production',
entry: {
polyfills: "./src/polyfills.ts",
app: "./src/main.prod.ts"
},
output: {
path: path.resolve(__dirname, 'dist'),
publicPath: '/',