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.

This commit is contained in:
SteveSandersonMS
2016-09-27 11:46:43 +01:00
parent 46966322b7
commit 30dfe5e8b5
3 changed files with 5 additions and 6 deletions

View File

@@ -67,8 +67,8 @@
"scripts": { "scripts": {
"prepublish": [ "prepublish": [
"npm install", "npm install",
"node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js", "node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod",
"node node_modules/webpack/bin/webpack.js" "node node_modules/webpack/bin/webpack.js --env.prod"
], ],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}, },

View File

@@ -1,8 +1,7 @@
var isDevBuild = process.argv.indexOf('--env.prod') < 0;
var path = require('path'); var path = require('path');
var webpack = require('webpack'); var webpack = require('webpack');
var isDevBuild = process.env.ASPNETCORE_ENVIRONMENT === 'Development';
module.exports = { module.exports = {
devtool: isDevBuild ? 'inline-source-map' : null, devtool: isDevBuild ? 'inline-source-map' : null,
resolve: { extensions: [ '', '.js', '.ts' ] }, resolve: { extensions: [ '', '.js', '.ts' ] },

View File

@@ -1,8 +1,8 @@
var isDevBuild = process.argv.indexOf('--env.prod') < 0;
var path = require('path'); var path = require('path');
var webpack = require('webpack'); var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin'); var ExtractTextPlugin = require('extract-text-webpack-plugin');
var extractCSS = new ExtractTextPlugin('vendor.css'); var extractCSS = new ExtractTextPlugin('vendor.css');
var isDevelopment = process.env.ASPNETCORE_ENVIRONMENT === 'Development';
module.exports = { module.exports = {
resolve: { resolve: {
@@ -47,7 +47,7 @@ module.exports = {
path: path.join(__dirname, 'wwwroot', 'dist', '[name]-manifest.json'), path: path.join(__dirname, 'wwwroot', 'dist', '[name]-manifest.json'),
name: '[name]_[hash]' name: '[name]_[hash]'
}) })
].concat(isDevelopment ? [] : [ ].concat(isDevBuild ? [] : [
new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } }) new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } })
]) ])
}; };