From 30dfe5e8b5143cee0b55f6970c666e2bd6537339 Mon Sep 17 00:00:00 2001 From: SteveSandersonMS Date: Tue, 27 Sep 2016 11:46:43 +0100 Subject: [PATCH] In Angular2Spa webpack config, use "--env.prod" arg to trigger prod builds instead of ASPNETCORE_ENVIRONMENT env var. This is to guarantee production mode when publishing. --- templates/Angular2Spa/project.json | 4 ++-- templates/Angular2Spa/webpack.config.js | 3 +-- templates/Angular2Spa/webpack.config.vendor.js | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/templates/Angular2Spa/project.json b/templates/Angular2Spa/project.json index c9066fc..1409429 100755 --- a/templates/Angular2Spa/project.json +++ b/templates/Angular2Spa/project.json @@ -67,8 +67,8 @@ "scripts": { "prepublish": [ "npm install", - "node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js", - "node node_modules/webpack/bin/webpack.js" + "node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod", + "node node_modules/webpack/bin/webpack.js --env.prod" ], "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] }, diff --git a/templates/Angular2Spa/webpack.config.js b/templates/Angular2Spa/webpack.config.js index 9d1b48c..ffbfd47 100644 --- a/templates/Angular2Spa/webpack.config.js +++ b/templates/Angular2Spa/webpack.config.js @@ -1,8 +1,7 @@ +var isDevBuild = process.argv.indexOf('--env.prod') < 0; var path = require('path'); var webpack = require('webpack'); -var isDevBuild = process.env.ASPNETCORE_ENVIRONMENT === 'Development'; - module.exports = { devtool: isDevBuild ? 'inline-source-map' : null, resolve: { extensions: [ '', '.js', '.ts' ] }, diff --git a/templates/Angular2Spa/webpack.config.vendor.js b/templates/Angular2Spa/webpack.config.vendor.js index 9c03275..7c78efd 100644 --- a/templates/Angular2Spa/webpack.config.vendor.js +++ b/templates/Angular2Spa/webpack.config.vendor.js @@ -1,8 +1,8 @@ +var isDevBuild = process.argv.indexOf('--env.prod') < 0; var path = require('path'); var webpack = require('webpack'); var ExtractTextPlugin = require('extract-text-webpack-plugin'); var extractCSS = new ExtractTextPlugin('vendor.css'); -var isDevelopment = process.env.ASPNETCORE_ENVIRONMENT === 'Development'; module.exports = { resolve: { @@ -47,7 +47,7 @@ module.exports = { path: path.join(__dirname, 'wwwroot', 'dist', '[name]-manifest.json'), name: '[name]_[hash]' }) - ].concat(isDevelopment ? [] : [ + ].concat(isDevBuild ? [] : [ new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } }) ]) };