var isDevBuild = process.argv.indexOf('--env.prod') < 0;
var path = require('path');
var webpack = require('webpack');
var AureliaWebpackPlugin = require('aurelia-webpack-plugin');
var srcDir = path.resolve('./ClientApp');
var rootDir = path.resolve();
var outDir = path.resolve('./wwwroot/dist');
var baseUrl = '/';
var project = require('./package.json');
var aureliaModules = Object.keys(project.dependencies).filter(dep => dep.startsWith('aurelia-'));

// Configuration for client-side bundle suitable for running in browsers
var clientBundleConfig = {
     resolve: { extensions: [ '.js', '.ts' ] },
     devtool: isDevBuild ? 'inline-source-map' : null,
     entry: {
        'app': [], // <-- this array will be filled by the aurelia-webpack-plugin
        'aurelia-modules': aureliaModules
    },
    output: {
        path: outDir,
        publicPath: '/dist',
        filename: '[name]-bundle.js'
    },
    module: {
        loaders: [
            {
                test: /\.ts$/,
                include: /ClientApp/,
                loader: 'ts',
                query: {silent: true}
            }, {
                test: /\.html$/,
                exclude: /index\.html$/,
                loader: 'html-loader'
            }, {
                test: /\.css$/,
                loaders: ['style-loader', 'css-loader']
            }, {
                test: /\.(png|woff|woff2|eot|ttf|svg)$/,
                loader: 'url-loader?limit=100000'
            }
        ]
    },
    plugins: [
        new webpack.ProvidePlugin({
            $: 'jquery', // because 'bootstrap' by Twitter depends on this
            jQuery: 'jquery'
        }),
        new AureliaWebpackPlugin({
            root: rootDir,
            src: srcDir,
            baseUrl: baseUrl
        }),
        new webpack.optimize.CommonsChunkPlugin({
            name: ['aurelia-modules']
        }),
    ].concat(isDevBuild ? [] : [
        // Plugins that apply in production builds only
        new webpack.optimize.UglifyJsPlugin()
    ])
};

module.exports = [clientBundleConfig];

@@ -178,856 +178,788 @@
 ');%0A
-var srcDir = path.resolve('./ClientApp');%0Avar rootDir = path.resolve();%0Avar outDir = path.resolve('./wwwroot/dist');%0Avar baseUrl = '/';%0Avar project = require('./package.json');%0Avar aureliaModules = Object.keys(project.dependencies).filter(dep =%3E dep.startsWith('aurelia-'));%0A%0A// Configuration for client-side bundle suitable for running in browsers%0Avar clientBundleConfig = %7B%0A     resolve: %7B extensions: %5B '.js', '.ts' %5D %7D,%0A     devtool: isDevBuild ? 'inline-source-map' : null,%0A     entry: %7B%0A        'app': %5B%5D, // %3C-- this array will be filled by the aurelia-webpack-plugin%0A        'aurelia-modules': aureliaModules%0A    %7D,%0A    output: %7B%0A        path: outDir,%0A        publicPath: '/dist',%0A        filename: '%5Bname%5D-bundle.js'
+%0Amodule.exports = %7B%0A     resolve: %7B extensions: %5B '.js', '.ts' %5D %7D,%0A     devtool: isDevBuild ? 'inline-source-map' : null,%0A     entry: %7B%0A        'app': %5B%5D, // %3C-- this array will be filled by the aurelia-webpack-plugin%0A        'aurelia-modules': %5B%0A            'aurelia-bootstrapper-webpack',%0A            'aurelia-event-aggregator',%0A            'aurelia-fetch-client',%0A            'aurelia-framework',%0A            'aurelia-history-browser',%0A            'aurelia-loader-webpack',%0A            'aurelia-logging-console',
 %0A    
-%7D,%0A
     
-module: %7B%0A        loaders: %5B%0A            %7B%0A                test: /%5C.ts$/,%0A                include: /ClientApp/,
+    'aurelia-pal-browser',%0A            'aurelia-polyfills',%0A            'aurelia-route-recognizer',%0A            'aurelia-router',%0A            'aurelia-templating-binding',%0A            'aurelia-templating-resources',%0A            'aurelia-templating-router'
 %0A   
@@ -967,90 +967,183 @@
     
+%5D%0A
     
+%7D,%0A
     
-loader: 'ts',%0A                query: %7Bsilent: true%7D
+output: %7B%0A        path: path.resolve('./wwwroot/dist'),%0A        publicPath: '/dist',%0A        filename: '%5Bname%5D-bundle.js'
 %0A    
+%7D,%0A
     
-    %7D, %7B%0A     
+module: %7B%0A        loaders: %5B%0A
     
@@ -1140,32 +1140,35 @@
 rs: %5B%0A          
+  %7B
  test: /%5C.html$/
@@ -1165,72 +1165,105 @@
  /%5C.
-html$/,%0A                exclude: /index%5C.html$/,%0A               
+ts$/, include: /ClientApp/, loader: 'ts', query: %7Bsilent: true%7D %7D,%0A            %7B test: /%5C.html$/,
  loa
@@ -1280,37 +1280,20 @@
 -loader'
-%0A            %7D, %7B%0A   
+ %7D,%0A
         
@@ -1288,32 +1288,33 @@
  %7D,%0A            
+%7B
  test: /%5C.css$/,
@@ -1313,32 +1313,16 @@
 %5C.css$/,
-%0A               
  loaders
@@ -1357,25 +1357,11 @@
 er'%5D
-%0A           
  %7D,
- %7B
 %0A   
@@ -1369,19 +1369,17 @@
         
-   
+%7B
  test: /
@@ -1415,24 +1415,8 @@
 )$/,
-%0A               
  loa
@@ -1445,28 +1445,16 @@
 =100000'
-%0A           
  %7D%0A     
@@ -1519,22 +1519,28 @@
 in(%7B
-%0A            $
+ $: 'jquery', jQuery
 : 'j
@@ -1545,16 +1545,19 @@
 'jquery'
+ %7D)
 , // bec
@@ -1565,18 +1565,17 @@
 use 
-'b
+B
 ootstrap
 ' by
@@ -1574,77 +1574,43 @@
 trap
-' by Twitter depends on this%0A            jQuery: 'jquery'%0A        %7D),
+ expects $ and jQuery to be globals
 %0A   
@@ -1663,15 +1663,26 @@
 ot: 
-rootDir
+path.resolve('./')
 ,%0A  
@@ -1700,14 +1700,35 @@
 rc: 
-srcDir
+path.resolve('./ClientApp')
 ,%0A  
@@ -1746,23 +1746,19 @@
 aseUrl: 
-baseUrl
+'/'
 %0A       
@@ -2011,44 +2011,4 @@
 %0A%7D;%0A
-%0Amodule.exports = %5BclientBundleConfig%5D;%0A

Simplify AureliaSpa's webpack.config.js