Skip to content

CLI generated webpack config uses a specific host:port for the dev server websocket client #967

@chrisckc

Description

@chrisckc

I'm submitting a feature request

Current behavior:
When running a CLI generated project based on webpack, the path used by the webpack dev server client to make it's websocket requests is unnecessarily specified to be the same as the host:port specified in the aurelia.json and run.ts files. (port is specified in aurelia.json and host in run.ts)

Specifying the host:port is not required as it is derived from window.location and output.publicPath in the webpack.config.

This does not cause a problem in a simple app, but becomes apparent when you start to do something like run behind a reverse proxy during development, like in the case of using Aurelia with .NET Core using the new SpaProxy. Refer to this issue that i logged and closed: aspnet/JavaScriptServices#1743

This issue did not occur using Angular, because the webpack config behind the Angular CLI did not specify a specific host:port for the dev server client.

The fix is to change the following in 'aurelia_project/tasks/run.ts'

config.entry.app.unshift(`webpack-dev-server/client?http://${opts.host}:${opts.port}/`, 'webpack/hot/dev-server');

to this:

config.entry.app.unshift(`webpack-dev-server/client`, 'webpack/hot/dev-server');
  • What is the expected behavior?
    I should have been able to (or was hoping that i could) transplant the Angular app inside a dotnet new angular generated project with an Aurelia app with no changes required in the Aurelia app.

  • What is the motivation / use case for changing the behavior?
    Now that Microsoft have retired their Aurelia SPA template which is no longer available in dotnet v2.1 which uses the new SpaProxy based templates, making it easier to switch it over to Aurelia may help stem the resulting inevitable decline in Aurelia adoption rates for .NET users.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions