From efbfd9184ee3302798511e6fdcdfbadbba2a10b9 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Tue, 13 Feb 2018 17:22:10 -0500 Subject: [PATCH] enable prod mode for angular --- src/app/main.ts | 6 ++++++ src/scripts/utils.ts | 7 +++++++ src/services/desktopPlatformUtils.service.ts | 6 ++++++ 3 files changed, 19 insertions(+) create mode 100644 src/scripts/utils.ts diff --git a/src/app/main.ts b/src/app/main.ts index e9d6b19721..fab9cae260 100644 --- a/src/app/main.ts +++ b/src/app/main.ts @@ -1,6 +1,8 @@ import { enableProdMode } from '@angular/core'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; +import { isDev } from '../scripts/utils'; + // tslint:disable-next-line require('../scss/styles.scss'); // tslint:disable-next-line @@ -8,4 +10,8 @@ require('../scripts/duo.js'); import { AppModule } from './app.module'; +if (!isDev()) { + enableProdMode(); +} + platformBrowserDynamic().bootstrapModule(AppModule); diff --git a/src/scripts/utils.ts b/src/scripts/utils.ts new file mode 100644 index 0000000000..b4fe394889 --- /dev/null +++ b/src/scripts/utils.ts @@ -0,0 +1,7 @@ +export function isDev() { + // ref: https://github.com/sindresorhus/electron-is-dev + if ('ELECTRON_IS_DEV' in process.env) { + return parseInt(process.env.ELECTRON_IS_DEV, 10) === 1; + } + return (process.defaultApp || /node_modules[\\/]electron[\\/]/.test(process.execPath)); +} diff --git a/src/services/desktopPlatformUtils.service.ts b/src/services/desktopPlatformUtils.service.ts index f58b453ddf..9b94751f03 100644 --- a/src/services/desktopPlatformUtils.service.ts +++ b/src/services/desktopPlatformUtils.service.ts @@ -1,5 +1,7 @@ import { remote, shell } from 'electron'; +import { isDev } from '../scripts/utils'; + import { DeviceType } from 'jslib/enums'; import { I18nService } from 'jslib/abstractions/i18n.service'; @@ -143,4 +145,8 @@ export class DesktopPlatformUtilsService implements PlatformUtilsService { return Promise.resolve(result === 0); } + + isDev(): boolean { + return isDev(); + } }