From 7fcb6a2d7cae7a1482b487859c9adb7f239cab7d Mon Sep 17 00:00:00 2001 From: Shawn Doucet Date: Wed, 26 Apr 2017 17:50:28 -0500 Subject: [PATCH] enable hot module reload --- .gitignore | 1 + templates/AureliaSpa/Startup.cs | 2 +- templates/AureliaSpa/package.json | 31 ++++++++--------------- templates/AureliaSpa/webpack.config.js | 35 ++++++++++++++++++-------- 4 files changed, 38 insertions(+), 31 deletions(-) diff --git a/.gitignore b/.gitignore index 100aa3b9..d87f6b5d 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,4 @@ npm-debug.log .vscode/ /templates/*/Properties/launchSettings.json +/templates/AureliaSpa/Aurelia/Aurelia.sln diff --git a/templates/AureliaSpa/Startup.cs b/templates/AureliaSpa/Startup.cs index 412b4db7..cbaf6145 100644 --- a/templates/AureliaSpa/Startup.cs +++ b/templates/AureliaSpa/Startup.cs @@ -43,7 +43,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF app.UseDeveloperExceptionPage(); app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions { - HotModuleReplacement = false // Aurelia Webpack Plugin HMR currently has issues. Leave this set to false. + HotModuleReplacement = true }); } else diff --git a/templates/AureliaSpa/package.json b/templates/AureliaSpa/package.json index 912b7a32..45139253 100644 --- a/templates/AureliaSpa/package.json +++ b/templates/AureliaSpa/package.json @@ -2,28 +2,19 @@ "name": "WebApplicationBasic", "version": "0.0.0", "dependencies": { - "aurelia-bootstrapper-webpack": "^1.0.0", - "aurelia-event-aggregator": "^1.0.0", - "aurelia-fetch-client": "^1.0.0", - "aurelia-framework": "^1.0.0", - "aurelia-history-browser": "^1.0.0", - "aurelia-loader-webpack": "^1.0.0", - "aurelia-logging-console": "^1.0.0", - "aurelia-pal-browser": "^1.0.0", - "aurelia-polyfills": "^1.0.0", - "aurelia-route-recognizer": "^1.0.0", - "aurelia-router": "^1.0.2", - "aurelia-templating-binding": "^1.0.0", - "aurelia-templating-resources": "^1.0.0", - "aurelia-templating-router": "^1.0.0", + "aspnet-webpack": "^1.0.28", + "aurelia-bootstrapper": "^2.1.1", + "aurelia-fetch-client": "^1.1.2", + "aurelia-http-client": "^1.1.1", + "bluebird": "^3.5.0", "bootstrap": "^3.3.7", "isomorphic-fetch": "^2.2.1", "jquery": "^2.2.1" }, "devDependencies": { "@types/node": "^6.0.45", - "aspnet-webpack": "^1.0.11", - "aurelia-webpack-plugin": "^1.1.0", + "aspnet-webpack": "^1.0.28", + "aurelia-webpack-plugin": "^2.0.0-rc.2", "copy-webpack-plugin": "^3.0.1", "css": "^2.2.1", "css-loader": "^0.25.0", @@ -36,11 +27,11 @@ "raw-loader": "^0.5.1", "style-loader": "^0.13.1", "to-string-loader": "^1.1.5", - "ts-loader": "^0.8.2", - "typescript": "^2.2.1", + "ts-loader": "^2.0.3", + "typescript": "^2.2.2", "url-loader": "^0.5.7", - "webpack": "2.1.0-beta.25", - "webpack-hot-middleware": "^2.10.0" + "webpack": "^2.3.3", + "webpack-hot-middleware": "^2.18.0" }, "aurelia": { "build": { diff --git a/templates/AureliaSpa/webpack.config.js b/templates/AureliaSpa/webpack.config.js index e529b58d..b7513a74 100644 --- a/templates/AureliaSpa/webpack.config.js +++ b/templates/AureliaSpa/webpack.config.js @@ -1,12 +1,19 @@ var isDevBuild = process.argv.indexOf('--env.prod') < 0; var path = require('path'); var webpack = require('webpack'); -var AureliaWebpackPlugin = require('aurelia-webpack-plugin'); - +const { AureliaPlugin } = require("aurelia-webpack-plugin"); +console.log("isDevBuild=" + isDevBuild); var bundleOutputDir = './wwwroot/dist'; module.exports = { - resolve: { extensions: [ '.js', '.ts' ] }, - entry: { 'app': 'aurelia-bootstrapper-webpack' }, // Note: The aurelia-webpack-plugin will add your app's modules to this bundle automatically + resolve: { + extensions: ['.js', '.ts'], + modules: ['ClientApp','node_modules'] + }, + entry: { + 'app': [ + 'webpack-hot-middleware/client?reload=true', + 'aurelia-bootstrapper'] + }, // Note: The aurelia-webpack-plugin will add your app's modules to this bundle automatically output: { path: path.resolve(bundleOutputDir), publicPath: '/dist', @@ -16,22 +23,30 @@ module.exports = { loaders: [ { test: /\.ts$/, include: /ClientApp/, loader: 'ts-loader', query: { silent: true } }, { test: /\.html$/, loader: 'html-loader' }, - { test: /\.css$/, loaders: [ 'style-loader', isDevBuild ? 'css-loader' : 'css-loader?minimize' ] }, + { test: /\.css$/, loader: 'raw-loader' }, { test: /\.(png|woff|woff2|eot|ttf|svg)$/, loader: 'url-loader?limit=100000' }, { test: /\.json$/, loader: 'json-loader' } ] }, plugins: [ + new AureliaPlugin({ + //https://github.com/jods4/aurelia-webpack-build/wiki/AureliaPlugin%20options + root: path.resolve('./'), + includeAll: 'ClientApp', + baseUrl: '/', + aureliaApp: "boot", + features: { + ie: true, + svg: false, + unparser: true + } + }), new webpack.DefinePlugin({ IS_DEV_BUILD: JSON.stringify(isDevBuild) }), new webpack.DllReferencePlugin({ context: __dirname, manifest: require('./wwwroot/dist/vendor-manifest.json') }), - new AureliaWebpackPlugin({ - root: path.resolve('./'), - src: path.resolve('./ClientApp'), - baseUrl: '/' - }) + ].concat(isDevBuild ? [ // Plugins that apply in development builds only new webpack.SourceMapDevToolPlugin({