-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Skip contenthash when not production #3060
Skip contenthash when not production #3060
Conversation
Hey @justin808, this PR looks like it reverts the changes made in #2954, which implemented a fix for stylesheets not being reloaded in certain browsers in development. Would the issue described in that PR return if these changes were merged? Code-wise it seems to revert settings for the MiniCssExtractPlugin to what they were before #2954 was merged if I see correctly? |
package/environments/base.js
Outdated
}) | ||
) | ||
} | ||
|
||
return plugins | ||
} | ||
|
||
// Don't use contentHash except for production for performance | ||
// https://webpack.js.org/guides/build-performance/#avoid-production-specific-tooling | ||
const filenameHash = isProduction ? '-[contenthash]' : ''; |
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.
const filenameHash = isProduction ? '-[contenthash]' : ''; | |
const hash = isProduction ? '-[contenthash]' : ''; |
For consistency
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.
We are not using semicolons at all. So should strip instead.
CSS gets the |
Per the webpack docs on better performance, the contenthash should be skipped when not on production. https://webpack.js.org/guides/build-performance/#avoid-production-specific-tooling
e2309f0
to
24a01d8
Compare
@guillaumebriday Comments addressed. Tomorrow, HST, I'll try to update https://github.com/shakacode/react_on_rails_tutorial_with_ssr_and_hmr_fast_refresh with this change to test this out. |
24a01d8
to
96062a7
Compare
I'm slightly perplexed as to what the end result is going to be now. For those of use using webpacker for straight up JS and CSS use (no react), does this plus HMR allow in dev mode to let us change JS and CSS and have those changes be shown in the browser? If the filenames rename the same, browsers will treat it as a cached file and not attempt to pull in the new code. That would force developers to run their browsers with caching disabled via the network tab in the inspector. That was the whole point of adding the hashes in #2954 for CSS as the JS code was being refreshed on save but not the CSS. |
A more specific example: I have apps thare are simply turbo, stimulus, and tailwind all going through the current webpacker beta. No react. No SSR. Just straight up bundled JS and CSS. I start up |
I'm pretty sure that the Rails server lets the browser know to not cache the files during development. |
Appolgies if I came off strong earlier. I managed (barely) to get master hooked up to an app and did confirm that these changes (plus #3031) does appear to properly refresh any changed CSS and JS (at least with some limited local testing). The whole webpack/JS ecosystem is still a bit of a black box to me, but somehow this is pushing changes without having to have file names with different hashes in them. 🤷 |
Per the webpack docs on better performance, the contenthash should be
skipped when not on production.
https://webpack.js.org/guides/build-performance/#avoid-production-specific-tooling