Previously bud would expose the site on http://localhost:3000 but this is not the case with the updated Vite version. I get nothing on that URL.
I see this in the terminal when running yarn dev (or npm run dev)
VITE v6.0.7 ready in 112 ms
➜ Local: http://localhost:5173/app/themes/chill/public/build/
➜ Network: use --host to expose
➜ press h + enter to show help
LARAVEL plugin v1.1.1
➜ APP_URL: undefined
Tried putting an APP_URL value in my .env to no avail. Tried the default Laravel port of of 8000 but again nothing.
Any clues? Docs are out of date as they are still all on bud. Thanks in advance
Gotcha, just checking since Vite in this configuration will ideally not need a dev URL. I’m going to attempt to switch one of my projects over some time this week and will see if I can’t help squash any issues I come across.
Thanks @ben - I followed these steps from scratch and found the source of the problem:
It is an issue with Brave browser. If shields are UP for the test domain, it shows unstyled HTML and nothing works. You need to disable shields for your test domains then everything works fine.
I can also confirm that hot reloading works perfectly when I make further changes to app.css.
There is an error about @wordpress/dom-ready not being found when loading the admin side, and no styles load in admin, but I guess they are different problems.
I noticed that if you run npm install then npm run dev without an intermediate npm run build you get this error:
npm run dev
> dev
> vite
node:internal/fs/utils:351
throw err;
^
Error: ENOENT: no such file or directory, open 'public/hot'
at Object.openSync (node:fs:590:3)
at Object.writeFileSync (node:fs:2295:35)
at Server.<anonymous> (file:///Users/stevejones/Sites/client/springboard/web/app/themes/spring/node_modules/laravel-vite-plugin/dist/index.js:103:14)
at Object.onceWrapper (node:events:625:28)
at Server.emit (node:events:523:35)
at emitListeningNT (node:net:1857:10)
at process.processTicksAndRejections (node:internal/process/task_queues:81:21) {
errno: -2,
syscall: 'open',
code: 'ENOENT',
path: 'public/hot'
}
Node.js v20.1.0
As soon as you run npm run build and re-run npm run dev it’s fine.
Can confirm the latest commit fixes the dependency error.
I’m not sure if I should have expecting the iframe styles issue to have been resolved with this new approach, but styles don’t load on the admin site when supplied via editor.css - fine on the front side.
This doesn’t solve the issue of injecting styles into the iframe, but if it unblocks you, I would try a plugin that registers a very basic api version 2 block, while env is development (if using bedrock). Having any v2 blocks registered appears to disable the iframe editor.
Hi @csorrentino - using an API v2 block is the approach I’ve been using for the entire lifecyle of bud.js but I am really hopeful that @ben can solve it once and for all (with hot reloading) without having to use this hack.
If we end up having to do some sort of hack to enforce a non-iframed editor in dev mode, the setup in main right now (without Tailwind v4/#3208’s changes) will work
Agreed! Just started a new project with the Vite codebase and very happy with it so far.
Removing Tailwind doesn’t seem to be too difficult either. Most of the changes have to be made in the wordpressThemeJson function in resources/js/build/wordpress.js in addition to removing the config, packages and relevant imports.
I just moved it out of wp_head directly into the app layout using the @vite directive.
For a localize script in the current configuration, you’d need to either use a hook on wp_footer or handle it directly in the app layout or your footer component using the @js Blade directive like:
<script>
var test = @js(['test', 'test2']);
console.log(test);
</script>
Inline script is preferred over localize (I’m still training myself to do this ), and if you really want to do things the WP way, you could follow this method:
Ah - its always been the need for a dependency I don’t need that has put me off this approach. Being able to do it without does indeed sound like a nice way to do it going forward.