Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

dev-server: Stop setting contentBase #1165

Merged
merged 1 commit into from
Oct 11, 2018
Merged

dev-server: Stop setting contentBase #1165

merged 1 commit into from
Oct 11, 2018

Conversation

edmorley
Copy link
Member

@edmorley edmorley commented Oct 11, 2018

By default webpack-dev-server attempts to serve webpack-generated files in response to requests, followed by passing them on to any proxy (if set). However when the contentBase setting is used, requests can also fall back to any file in the specified directory, even if it's not part of the webpack build:
https://webpack.js.org/configuration/dev-server/#devserver-contentbase

This can cause confusion since when performing a production build, webpack-dev-server isn't used so no such fallback occurs, meaning a seemingly working dev site then might not work in production.

The contentBase option has been set since Neutrino 4:
30e3f5b#diff-92e7b3255c5e8759497a7b3247b2e1e8R161

...and I believe is a leftover from the time when copy-webpack-plugin (prior to v2.0.1) didn't support making the copied files available to webpack-dev-server.

@edmorley edmorley added this to the v9 milestone Oct 11, 2018
@edmorley edmorley self-assigned this Oct 11, 2018
By default webpack-dev-server attempts to serve webpack-generated
files in response to requests, followed by passing them on to any
proxy (if set). However when the `contentBase` setting is used,
requests can also fall back to any file in the specified directory,
even if it's not part of the webpack build.

This can cause confusion since when performing a production build,
webpack-dev-server isn't used so no such fallback occurs, meaning
a seemingly working dev site then might not work in production.

The `contentBase` option has been set since Neutrino 4:
30e3f5b#diff-92e7b3255c5e8759497a7b3247b2e1e8R161

...and I believe is a leftover from the time when `copy-webpack-plugin`
(prior to v2.0.1) didn't support making the copied files available to
webpack-dev-server.
Copy link
Contributor

@timkelty timkelty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, this sounds/looks right to me! Did a quick test and didn't break anything for me on an existing project, either.

@edmorley edmorley merged commit 7c60814 into neutrinojs:master Oct 11, 2018
@edmorley edmorley deleted the devserver-no-contentbase branch October 11, 2018 18:54
@edmorley edmorley added the bug label Oct 11, 2018
@edmorley
Copy link
Member Author

Thank you for the review(s) :-)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging this pull request may close these issues.

2 participants