prod environment settings

This commit is contained in:
Kyle Spearrin 2018-04-13 15:14:04 -04:00
parent 76eeb4e41d
commit dc35577564
6 changed files with 34 additions and 11 deletions

10
package-lock.json generated
View File

@ -2620,6 +2620,16 @@
"sha.js": "2.4.10"
}
},
"cross-env": {
"version": "5.1.4",
"resolved": "https://registry.npmjs.org/cross-env/-/cross-env-5.1.4.tgz",
"integrity": "sha512-Mx8mw6JWhfpYoEk7PGvHxJMLQwQHORAs8+2bX+C1lGQ4h3GkDb1zbzC2Nw85YH9ZQMlO0BHZxMacgrfPmMFxbg==",
"dev": true,
"requires": {
"cross-spawn": "5.1.0",
"is-windows": "1.0.2"
}
},
"cross-spawn": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz",

View File

@ -6,13 +6,14 @@
"sub:update": "git submodule update --remote",
"sub:pull": "git submodule foreach git pull",
"postinstall": "npm run sub:init",
"start:firefox": "web-ext run --source-dir ./dist/",
"build": "gulp build && webpack --config webpack.config.js",
"build:watch": "gulp build && webpack --config webpack.config.js --watch",
"dist": "npm run build && gulp dist",
"dist:firefox": "npm run build && gulp dist:firefox",
"dist:opera": "npm run build && gulp dist:opera",
"dist:safari": "npm run build && gulp dist:safari",
"build:prod": "gulp build && cross-env NODE_ENV=production webpack --config webpack.config.js",
"build:prod:watch": "gulp build && cross-env NODE_ENV=production webpack --config webpack.config.js --watch",
"dist": "npm run build:prod && gulp dist",
"dist:firefox": "npm run build:prod && gulp dist:firefox",
"dist:opera": "npm run build:prod && gulp dist:opera",
"dist:safari": "npm run build:prod && gulp dist:safari",
"lint": "tslint src/**/*.ts || true",
"lint:fix": "tslint src/**/*.ts --fix",
"test": "karma start --single-run",
@ -43,6 +44,7 @@
"clean-webpack-plugin": "^0.1.17",
"clipboard": "1.7.1",
"copy-webpack-plugin": "^4.2.0",
"cross-env": "^5.1.4",
"css-loader": "^0.28.7",
"del": "3.0.0",
"extract-text-webpack-plugin": "^3.0.1",

View File

@ -262,7 +262,8 @@ export class BrowserApi {
}
static gaFilter() {
return BrowserApi.isSafariApi && safari.application.activeBrowserWindow.activeTab.private;
return process.env.ENV !== 'production' ||
(BrowserApi.isSafariApi && safari.application.activeBrowserWindow.activeTab.private);
}
static getUILanguage(win: Window) {

View File

@ -9,8 +9,8 @@ require('../scripts/duo.js');
import { AppModule } from './app.module';
// if (!isDev()) {
// enableProdMode();
// }
if (process.env.ENV === 'production') {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule);

View File

@ -80,10 +80,10 @@ export function initFactory(i18nService: I18nService, storageService: StorageSer
window.document.documentElement.classList.add('locale_' + i18nService.translationLocale);
authService.init();
new Analytics(window, () => BrowserApi.gaFilter(), null, null, null, () => {
const analytics = new Analytics(window, () => BrowserApi.gaFilter(), null, null, null, () => {
const bgPage = BrowserApi.getBackgroundPage();
if (bgPage == null || bgPage.bitwardenMain == null) {
throw 'Cannot resolve background page main.';
throw new Error('Cannot resolve background page main.');
}
return bgPage.bitwardenMain;
});

View File

@ -6,6 +6,11 @@ const CopyWebpackPlugin = require('copy-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const AngularCompilerPlugin = require('@ngtools/webpack').AngularCompilerPlugin;
if (process.env.NODE_ENV == null) {
process.env.NODE_ENV = 'development';
}
const ENV = process.env.ENV = process.env.NODE_ENV;
const isVendorModule = (module) => {
if (!module.context) {
return false;
@ -159,6 +164,11 @@ const config = {
include: ['popup/main.js', 'background.js'],
}),
extractCss,
new webpack.DefinePlugin({
'process.env': {
'ENV': JSON.stringify(ENV)
}
}),
],
};