Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

enable hot module reload in the aurelia spa sample #898

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ npm-debug.log
.vscode/

/templates/*/Properties/launchSettings.json
/templates/AureliaSpa/Aurelia/Aurelia.sln
2 changes: 1 addition & 1 deletion templates/AureliaSpa/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 11 additions & 20 deletions templates/AureliaSpa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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": {
Expand Down
35 changes: 25 additions & 10 deletions templates/AureliaSpa/webpack.config.js
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -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({
Expand Down