Activate Angular production mode on master branch.

This commit is contained in:
Manuel Friedli 2017-03-15 03:57:59 +01:00
parent 38ff12070e
commit 5ef1848db2
4 changed files with 55 additions and 32 deletions

View file

@ -8,12 +8,28 @@ build_job:
stage: build
script:
- npm install
- npm run build
- npm run build-dev
- npm run test
tags:
- javascript
except:
- tags
- master
artifacts:
paths:
- dist
expire_in: 30 min
build_job_production:
stage: build
script:
- npm install
- npm run build
- npm run test
tags:
- javascript
only:
- master
artifacts:
paths:
- dist

View file

@ -4,9 +4,9 @@ var ExtractTextPlugin = require('extract-text-webpack-plugin');
var commonConfig = require('./webpack.common.js');
var helpers = require('./helpers');
const ENV = process.env.NODE_ENV = process.env.ENV = 'production';
module.exports = webpackMerge(commonConfig, {
module.exports = function (env) {
console.log("env:", env);
return webpackMerge(commonConfig, {
devtool: 'source-map',
output: {
@ -26,7 +26,7 @@ module.exports = webpackMerge(commonConfig, {
new ExtractTextPlugin('[name].[hash].css'),
new webpack.DefinePlugin({
'process.env': {
'ENV': JSON.stringify(ENV)
'NODE_ENV': JSON.stringify(env.NODE_ENV)
}
}),
new webpack.LoaderOptionsPlugin({
@ -36,3 +36,4 @@ module.exports = webpackMerge(commonConfig, {
})
]
});
};

View file

@ -66,6 +66,7 @@
"scripts": {
"start": "webpack-dev-server --inline --progress --port 8080",
"test": "karma start",
"build": "rimraf dist && webpack --config config/webpack.prod.js --progress --profile --bail"
"build-dev": "rimraf dist && webpack --config config/webpack.prod.js --progress --profile --bail --env.NODE_ENV=development",
"build": "rimraf dist && webpack --config config/webpack.prod.js --progress --profile --bail --env.NODE_ENV=production"
}
}

View file

@ -1,4 +1,9 @@
import {platformBrowserDynamic} from "@angular/platform-browser-dynamic";
import {AppModule} from "./app/app.module";
import {enableProdMode} from "@angular/core";
if (process.env.NODE_ENV === "production") {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule);