I have built a few templates with bud.js now, recently with the new versions after ~6.6.9 (somewhere around there) I am having HMR issues.
I am getting cross origin errors.
I am on Windows 11 with WSL2. Everything works flawlessly on older versions in other projects.
Host: http://localhost/myTemplate
Dev: Host: http://localhost:3000/myTemplate
BudJS: 6.9.0
[myTemplate] built in 763ms
localhost/:1 Access to fetch at 'http://localhost/myTemplate/wp-content/themes/wptheme.myTemplate/dist/app.ebc0a3543555f706b65e.hot-update.json' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
I get the “green” dot of refresh confirmation on the bottom left of the browser. When I manually reload, everything is there, however it cannot get the individual HRM updates.
/**
* Build configuration for bud.js
* @param {import('@roots/bud').Bud} bud
*/
export default async bud => {
/**
* The bud instance
*/
bud
.when(
bud.isProduction,
() => bud.hash().minimize(),
)
/**
* Set the project source directory
*/
.setPath(`@src`, `sources`)
/**
* Set the application entrypoints
* These paths are expressed relative to the `@src` directory
*/
.entry({
app: [`scripts/app.js`, `styles/app.scss`], // [`./sources/scripts/app.js`, `./sources/styles/app.scss`]
editor: [`scripts/editor.js`, `styles/editor.scss`],
})
/**
* Copy static assets from `sources/static` to `dist/static`
*/
.assets({
from: bud.path(`@src/static`),
to: bud.path(`@dist/static`),
})
/** I tried lots of different combinations here **/
.proxy()
.serve({
host: 'localhost',
port: 3000
})
}