Skip to content

Commit

Permalink
fix(run-webpack.js run-webpack.ts index-webpack.ejs): update run scri…
Browse files Browse the repository at this point in the history
…pts, remove redundant entry in index template

Fixes issue where the webpack dev server client is added in both the index.ejs file
and also in 'aurelia_project/tasks/run.ts' when HMR is used.
Improves config by removing unnecessarily specified host:port on the dev server client
This avoids config issues when running behind a reverse proxy

Fixes the following issues:
#966
#967
  • Loading branch information
chrisckc committed Nov 22, 2018
1 parent b26a6a2 commit 9b3c171
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
4 changes: 0 additions & 4 deletions lib/resources/content/index-webpack.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,5 @@
<!-- imported CSS are concatenated and added automatically -->
</head>
<body aurelia-app="main">
<% if (htmlWebpackPlugin.options.metadata.server) { %>
<!-- Webpack Dev Server reload -->
<script src="/webpack-dev-server.js"></script>
<% } %>
</body>
</html>
8 changes: 7 additions & 1 deletion lib/resources/tasks/run-webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@ function runWebpack(done) {
}
};

// Add the webpack-dev-server client to the webpack entry point
// The path for the client to use such as `webpack-dev-server/client?http://${opts.host}:${opts.port}/` is not required
// The path used is derived from window.location in the browser and output.publicPath in the webpack.config.
if (project.platform.hmr || CLIOptions.hasFlag('hmr')) {
config.plugins.push(new webpack.HotModuleReplacementPlugin());
config.entry.app.unshift(`webpack-dev-server/client?http://${opts.host}:${opts.port}/`, 'webpack/hot/dev-server');
config.entry.app.unshift('webpack-dev-server/client', 'webpack/hot/dev-server');
} else {
// removed "<script src="/webpack-dev-server.js"></script>" from index.ejs in favour of this method
config.entry.app.unshift('webpack-dev-server/client');
}

const compiler = webpack(config);
Expand Down
8 changes: 7 additions & 1 deletion lib/resources/tasks/run-webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@ function runWebpack(done) {
https: config.devServer.https
} as any;

// Add the webpack-dev-server client to the webpack entry point
// The path for the client to use such as `webpack-dev-server/client?http://${opts.host}:${opts.port}/` is not required
// The path used is derived from window.location in the browser and output.publicPath in the webpack.config.
if (project.platform.hmr || CLIOptions.hasFlag('hmr')) {
config.plugins.push(new webpack.HotModuleReplacementPlugin());
config.entry.app.unshift(`webpack-dev-server/client?http://${opts.host}:${opts.port}/`, 'webpack/hot/dev-server');
config.entry.app.unshift('webpack-dev-server/client', 'webpack/hot/dev-server');
} else {
// removed "<script src="/webpack-dev-server.js"></script>" from index.ejs in favour of this method
config.entry.app.unshift('webpack-dev-server/client');
}

const compiler = webpack(config);
Expand Down

0 comments on commit 9b3c171

Please sign in to comment.