-
Notifications
You must be signed in to change notification settings - Fork 3
Use output.path when inferring publicPath #156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
In a multiple-config Webpack setup, builds to two different output directories appear to both need a specified, unique publicPath in order for those bundles to be accessible as expected within the dev server. To ensure that default usage creates bundles which can be loaded correctly in a multi-config DevServer environment, we adapt the value of output.path (stripping out the filePath cwd base) for use as a subdirectory within the in-memory virtual filesystem of the DevServer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't pulled this code down and tested it with live configs to see if it accounts for every case I can throw at it, but it makes sense and the test coverage looks good.
There's a note in the dev config presets the public path needs to be set by the consumer. Should that comment be updated to note that the config will try to guess a useful public path if not specified?
tomjn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't see anything wrong here
**New Features** - Adapt the value of `output.path` when inferring `output.publicPath` in DevServer so that all assets are correctly served in multi-config situations. [#156](#156) - Generate a `production-asset-manifest.json` for all production preset builds. [#153](#153) Builds in a multi-configuration setup which target the same output folder will share a manifest. [#154](#154) **Upgrades & Changes** - **Potentially Breaking**: Update `mini-css-extract-plugin` to v1.3.4. [Changelog](https://github.com/webpack-contrib/mini-css-extract-plugin/blob/master/CHANGELOG.md). [#148](#148) - **Potentially Breaking**: Update `css-loader` to v5.0.1. [Changelog](https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md). [#136](#136) - **Potentially Breaking**: Update `style-loader` to v2.0.0. [Changelog](https://github.com/webpack-contrib/style-loader/blob/master/CHANGELOG.md). [#127](#127) All three of the above dependency upgrades include breaking API changes. None of these changes should impact vanilla usage of the [presets](https://humanmade.github.io/webpack-helpers/modules/presets.html) provided by these helpers, but we recommend reviewing all three libraries' changelogs to identify potential issues if you are [customizing presets or loader behavior](https://humanmade.github.io/webpack-helpers/modules/presets.html#customizing-presets) relating to stylesheets. - **Potentially Breaking**: Update `webpack-manifest-plugin` to v3.0.0. [Changelog](https://github.com/shellscape/webpack-manifest-plugin/releases). [#143](#143) The manifest plugin now exports its constructor as a named export, not a default, so any custom builds which pull in the `ManifestPlugin` constructor directly from the plugin dependency (as opposed to using the recommended `plugins.manifest()` factory function) will need to switch to using `plugins.constructors.ManifestPlugin`. This should not impact un-customized presets. - **Potentially Breaking**: Update `postcss-flexbugs-fixes` to v5.0.2 and update `postcss-loader` to v4.1.0. [#152](#152) The upgrade to `postcss-loader` requires nesting PostCSS configuration options within a `.postcssOptions` key on the object passed to the webpack loader. As with the style loading changes above, if you use the presets without customization this should not impact your project. Otherwise, ensure you have added this level of nesting to any code which customizes the `postcss-loader`'s configuration object. Consult the [`postcss-loader` changelog](https://github.com/webpack-contrib/postcss-loader/blob/master/CHANGELOG.md#-breaking-changes) for more information. - Upgrade `webpack-fix-style-only-entries` plugin to v0.6.0. This may resolve the issue previously documented in [#93](#93) where files would be incorrectly deleted when processing an array of webpack configuration objects. [#129](#129) - Include `postcss` as a direct dependency of this package, rather than a subdependency. [#151](#151) - Update `webpack-bundle-analyzer` bundled plugin to v4.3.0. [#146](#146) - Internal: Add the generation of a basic development and production bundle, including scss styles, to the CI job. [#149](#149) - Internal: Upgrade local development dependencies to latest versions. [#150](#150)
In a multiple-config Webpack setup, builds to two different output directories appear to both need a specified, unique publicPath in order for those bundles to be accessible as expected within the dev server.
To ensure that default usage creates bundles which can be loaded correctly in a multi-config DevServer environment, we adapt the value of output.path (stripping out the filePath cwd base) for use as a subdirectory within the in-memory virtual filesystem of the DevServer.
I encountered this behavior while testing v0.10-beta.1, and in a happy coincidence fixing it also fills in some of our
.todotests...