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",
"es6-shim": "^0.35.1",
"expose-loader": "^0.7.1",
"extendify": "^1.0.0",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.9.0",
"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 webpack = require('webpack');
var merge = require('extendify')({ isDeep: true, arrays: 'concat' });
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({
resolve: {
extensions: [ '', '.js', '.ts' ]
},
var isDevBuild = process.env.ASPNETCORE_ENVIRONMENT === 'Development';
var extractCSS = new ExtractTextPlugin('styles.css');
module.exports = {
devtool: isDevBuild ? 'inline-source-map' : null,
resolve: { extensions: [ '', '.js', '.ts' ] },
entry: { main: ['./ClientApp/boot-client.ts'] },
module: {
loaders: [
{ test: /\.ts$/, include: /ClientApp/, loader: 'ts-loader?silent=true' },
@@ -18,9 +16,6 @@ module.exports = merge({
{ test: /\.css/, loader: extractCSS.extract(['css']) }
]
},
entry: {
main: ['./ClientApp/boot-client.ts']
},
output: {
path: path.join(__dirname, 'wwwroot', 'dist'),
filename: '[name].js',
@@ -32,5 +27,9 @@ module.exports = merge({
context: __dirname,
manifest: require('./wwwroot/dist/vendor-manifest.json')
})
]
}, isDevelopment ? devConfig : prodConfig);
].concat(isDevBuild ? [] : [
// 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]'
})
].concat(isDevelopment ? [] : [
new webpack.optimize.UglifyJsPlugin({
compress: { warnings: false },
minimize: true,
mangle: false // Due to https://github.com/angular/angular/issues/6678
})
new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } })
])
};