Simplify webpack config. Eliminate dev/prod override files.

This commit is contained in:
SteveSandersonMS
2016-09-19 14:13:20 +01:00
parent 85dfdd9b50
commit 4ea7eb195e
5 changed files with 14 additions and 35 deletions

View File

@@ -34,7 +34,6 @@
"css-loader": "^0.25.0", "css-loader": "^0.25.0",
"es6-shim": "^0.35.1", "es6-shim": "^0.35.1",
"expose-loader": "^0.7.1", "expose-loader": "^0.7.1",
"extendify": "^1.0.0",
"extract-text-webpack-plugin": "^1.0.1", "extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.9.0", "file-loader": "^0.9.0",
"isomorphic-fetch": "^2.2.1", "isomorphic-fetch": "^2.2.1",

View File

@@ -1,3 +0,0 @@
module.exports = {
devtool: 'inline-source-map'
};

View File

@@ -1,16 +1,14 @@
var path = require('path'); var path = require('path');
var webpack = require('webpack'); var webpack = require('webpack');
var merge = require('extendify')({ isDeep: true, arrays: 'concat' });
var ExtractTextPlugin = require('extract-text-webpack-plugin'); var ExtractTextPlugin = require('extract-text-webpack-plugin');
var extractCSS = new ExtractTextPlugin('styles.css');
var devConfig = require('./webpack.config.dev');
var prodConfig = require('./webpack.config.prod');
var isDevelopment = process.env.ASPNETCORE_ENVIRONMENT === 'Development';
module.exports = merge({ var isDevBuild = process.env.ASPNETCORE_ENVIRONMENT === 'Development';
resolve: { var extractCSS = new ExtractTextPlugin('styles.css');
extensions: [ '', '.js', '.ts' ]
}, module.exports = {
devtool: isDevBuild ? 'inline-source-map' : null,
resolve: { extensions: [ '', '.js', '.ts' ] },
entry: { main: ['./ClientApp/boot-client.ts'] },
module: { module: {
loaders: [ loaders: [
{ test: /\.ts$/, include: /ClientApp/, loader: 'ts-loader?silent=true' }, { test: /\.ts$/, include: /ClientApp/, loader: 'ts-loader?silent=true' },
@@ -18,9 +16,6 @@ module.exports = merge({
{ test: /\.css/, loader: extractCSS.extract(['css']) } { test: /\.css/, loader: extractCSS.extract(['css']) }
] ]
}, },
entry: {
main: ['./ClientApp/boot-client.ts']
},
output: { output: {
path: path.join(__dirname, 'wwwroot', 'dist'), path: path.join(__dirname, 'wwwroot', 'dist'),
filename: '[name].js', filename: '[name].js',
@@ -32,5 +27,9 @@ module.exports = merge({
context: __dirname, context: __dirname,
manifest: require('./wwwroot/dist/vendor-manifest.json') manifest: require('./wwwroot/dist/vendor-manifest.json')
}) })
] ].concat(isDevBuild ? [] : [
}, isDevelopment ? devConfig : prodConfig); // Plugins that apply in production builds only
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin()
])
};

View File

@@ -1,12 +0,0 @@
var webpack = require('webpack');
module.exports = {
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: { warnings: false },
minimize: true,
mangle: false // Due to https://github.com/angular/angular/issues/6678
})
]
};

View File

@@ -49,10 +49,6 @@ module.exports = {
name: '[name]_[hash]' name: '[name]_[hash]'
}) })
].concat(isDevelopment ? [] : [ ].concat(isDevelopment ? [] : [
new webpack.optimize.UglifyJsPlugin({ new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } })
compress: { warnings: false },
minimize: true,
mangle: false // Due to https://github.com/angular/angular/issues/6678
})
]) ])
}; };