aspnet-webpack should take publicPath from devServer.publicPath first, then fallback to output.publicPath #134

Closed
opened 2025-08-09 17:15:08 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @rjgotten on 3/12/2018

Currently, the setting is hardcoded to be output.publicPath.

67560266ab/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-webpack/src/WebpackDevMiddleware.ts (L124)

There is supposed to be an explicit override in devServer.publicPath which can be used when the two do not match:

https://webpack.js.org/configuration/dev-server/#devserver-publicpath-

While it is recommended that both match, for more complex folder structures this is many times simply not possible due to peculiarities in how webpack and several mainstream plugins resolve paths.

This is in particular a problem with ASP.NET Core and the wwwroot folder, which doesn't exist in the URL structure; only on disk. Many webpack plugins that handle file path mapping (e.g. file-loader, extract-text, etc.) sort of rely on the disk path and url path being consistent.

*Originally created by @rjgotten on 3/12/2018* Currently, the setting is hardcoded to be `output.publicPath`. https://github.com/aspnet/JavaScriptServices/blob/67560266aba6d06226f6b6bc4df08f6ae5c65772/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-webpack/src/WebpackDevMiddleware.ts#L124 There is supposed to be an explicit override in `devServer.publicPath` which can be used when the two do not match: https://webpack.js.org/configuration/dev-server/#devserver-publicpath- While it is recommended that both match, for more complex folder structures this is many times simply not possible due to peculiarities in how webpack and several mainstream plugins resolve paths. This is in particular a problem with ASP.NET Core and the `wwwroot` folder, which doesn't exist in the URL structure; only on disk. Many webpack plugins that handle file path mapping (e.g. file-loader, extract-text, etc.) sort of rely on the disk path and url path being consistent.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#134
No description provided.