Permalink
Browse files

fix(run-webpack.js run-webpack.ts index-webpack.ejs): update run scri…

…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 9b3c171aea6beb389f09933bc607a209989fe020
@@ -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>
@@ -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);
@@ -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);

0 comments on commit 9b3c171

Please sign in to comment.