-
-
Notifications
You must be signed in to change notification settings - Fork 42
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
[bug] HMR not reloading on change of app.css, works with other entry files #1729
Comments
Some updated notes: eg: The following would listen to changes on the test bundle and reload add_action('wp_enqueue_scripts', function () {
bundle('app')->enqueue();
bundle('test')->enqueue();
}, 100); Whereas this only listens to changes on the app bundle add_action('wp_enqueue_scripts', function () {
bundle('test')->enqueue();
bundle('app')->enqueue();
}, 100); This may be a misunderstanding on my behalf - but it appears the HMR is only looking for the last registered bundle to reload - is this expected behavior? |
Hm is ur app.css valid? Or just a tailwind's default with some test classes added? |
Yes, valid css. They both compile fine. app.css: body {
background-color: black;
} test.scss $color: red;
body{
color: $color;
} |
At ok, because now starter is shipped with app.css with tailwind imports, which is import only file. Was confused why my test css was ignored |
To be clear, its loading both files , and compiling both files - the hot module reload is just only inserting the changes from the last file enqeued. |
this is a known thing with webpack (see webpack/webpack-dev-server#2792). my recommendation is to limit yourself to an entrypoint per page load. that's really how it's designed to be used. See example usage here: https://webpack.js.org/concepts/entry-points#multi-page-application. Note that the intent of that documentation is to show how to use multiple bundles so that they can be served on different pages. Not how to generate multiple bundles to be served on a single page. Historically, the most common reason people do this is to conditionally load assets, but today you can do that really easily without messing around with build tooling: const application = async () => {
if (document.body.classList.has(`landing-page-special`)) {
await import(`./conditional-script.js`)
}
} That said, you can still create a custom runtime for shared assets, if preferred. For example: export default async app => {
app
.entry({
shared: ['@styles/page-a', '@styles/page-b'],
[`page-a`]: {
import: [`@scripts/page-a`],
dependOn: [`shared`],
},
[`page-b`]: {
import: [`@scripts/page-b`],
dependOn: [`shared`],
},
})
} which would be enqueued like this: add_action('wp_enqueue_scripts', function () {
// always used
bundle('shared')->enqueue();
if (is_page('a')) {
bundle('page-a')->enqueue();
} else {
bundle('page-b')->enqueue();
}
}); In this example, both |
Message to comment on stale issues. If none provided, will not mark issues stale |
Agreement
Describe the issue
When using bud-ass + custom entry points + transpiler sources. the HMR does not work for the app.css within the sage theme, but does work when using the scss file in my custom entry point.
Details regarding the transpiler and entry point found in post #1728
Expected Behavior
reload changes regardless of which file is changed
Actual Behavior
Sometimes nothing, sometimes a console error:
Steps To Reproduce
bun dev
and edit the css/scss filesversion
6.4.4
What package manager are you using?
npm
version
8.15.0
Logs
No response
Configuration
No response
Relevant .budfiles
No response
The text was updated successfully, but these errors were encountered: