Bud is compiling very slow

I’m using Laragon on my Windows machine and figuring out why Bud is taking too much time to compile on WSL2 with a clean Bedrock and Sage install. I’ve read a lot of topics about it, but they haven’t worked for me. I was trying to switch to Laravel Mix, because Bud is pushing me to learn the new way with Sage 10 and can’t get it to work.

I saw that Sage 10 beta 1 was working with Laravel Mix, so I tried to implement Mix to the current version of Sage, but I got Symfony errors that the manifest.json file was not found.

I’m also getting errors proxying to localhost:3000 and I saw that a topic was already created about this (Yarn dev error with bud), but on Bud 5.7.6. I’m getting the same error. I have tried to switch permanently to BrowserSync and that was compiling fine, but localhost:3000 kept loading after it.

yarn run v1.22.18
$ bud dev
[99%] [done] MultiCompiler plugins

┌ assets ─────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                                                                                 │
│                                                                                                                 │
│  ✔    app                      app.js                      64.98 kB                                             │
│  ✔    editor                   editor.js                   55.96 kB                                             │
│  ✔    vendor/bud.app.editor    vendor/bud.app.editor.js    50.23 kB                                             │
│  ✔    ᠃                        manifest.json               113 bytes                                            │
│  ✔    ᠃                        entrypoints.json            109 bytes                                            │
│  ✔    ᠃                        wordpress.json              33 bytes                                             │
│                                                                                                                 │
│                                                                                                                 │
 duration    41s 215ms

 mode    development    hash       86ed3a1be2de59e2f4d7
 bud     5.7.6          webpack    5.70.0

 server url:    http://localhost:3000/
 proxy url:     http://bedrock.test/

[proxy] › ✖  [HPM] Error occurred while proxying request localhost:3000/ to http://bedrock.test/ [ECONNREFUSED] (https:/[proxy] › ✖  [HPM] Error occurred while proxying request localhost:3000/favicon.ico to http://bedrock.test/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)

Not a solution to the slow compilation on your machine, but if you do want to go down the Mix route, this might be worth checking out: Sage 10 with Laravel Mix instead of Bud

Yes, I saw that topic too, but that is not the final version of it I think. You need to manually add the entrypoints.json and manifest.json to the public folder or you will get an error from Symfony Encore that the manifest.json isn’t found.

It would be nice if I only use Mix for compiling and not Symfony Encore.

Hey there, I’m the creator of the laravel mix package.
I already added the manifest.json as well as the entrypoints.json to the latest versions, so it should now work.

Compilation works without symfony encore, however if you split it up in multiple files, you have to update the entrypoints.json file manually.

Hi @patrickzach! Thanks for the package. I have also tried to create my own Mix package with the current version of Sage. The beta 1 version of Sage was using it, so I tried to copy the webpack.mix.js and package.json config to it, but it seems not to work. I want to update Sage when I create a new project and try to understand how I can replace Bud with Laravel Mix.

The package you made requires manifest.json and entrypoints.json that are automatically created with Symfony Encore, so this still exists. What I want is only Mix. Like @lgt said in the topic, you will get an error in setup.php because Symfony Encore is expects a entrypoints.json. See below:

add_action('wp_enqueue_scripts', function () {
}, 100);

That is not what I want. I just want to use Laravel Mix for my entire project, so I’m trying to figure that out. Bud is pushing me to learn the new framework, but the compile time is way to slow on my machine. I still want to explore it, but also can’t figure that out. Maybe that you have a solution for me, @kellymears?

I have tried to copy the Laravel Mix config from the beta 1 of Sage like I said, but somehow it also asks for manifest.json and entrypoints.json.

It’s impossible to help figure out why your build is slow with the provided information. Can you provide a repo that reproduces your slow build? I know there are WSL users who are using bud without issue.

✖  [HPM] Error occurred while proxying request localhost:3000/ to http://bedrock.test/ [ECONNREFUSED]

Is bedrock.test accessible? http-proxy-middleware says its not.

From the environment where bud is running what is this output?

curl http://bedrock.test -i -s | sed -n 1,5p

You know how to complain that the proxy server is still running even though you are using browsersync. But, do you know how to disable the proxy server?


Hi @kellymears, thank you for your reply. First of all let’s make something clear that I’m just figuring out why is it so slow and not complaining :slight_smile: besides that I have figured a way to use Laravel Mix without Bud, but instead of changing this I want to use Bud how it is setup in Sage10.

I have also tested my Laravel Mix variant on powershell and wsl2. It looks like there is something wrong with my wsl2 installation, because it takes 5.4s to compile while powershell compiles it in 910ms. For the first 10 seconds it looks like wsl2 is stuck with compiling and compiles a little bit after that, so normally it takes more than 5.4s. It is the same with powershell, but a little bit faster.

Yes, bedrock.test is accessible.

Nothing :slightly_smiling_face:

I have a fresh installation of Sage10 and changed only the bud.config.js file with proxy and serve. I have tested several times with a new installation, but it gives me the same result.

The very first of time yarn build gives me this:

yarn run v1.22.18
$ bud build
[99%] [cache] begin idle

┌ assets ─────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                                                                                 │
│                                                                                                                 │
│  ⚡    app        app.521c12.css       4.03 kB                                                                  │
│  ⚡    runtime    runtime.194772.js    1.24 kB                                                                  │
│  ⚡    editor     editor.5f39da.js     769 bytes                                                                │
│  ⚡    app        app.f5abda.js        623 bytes                                                                │
│  ⚡    editor     editor.31d6cf.css    0 bytes                                                                  │
│        ᠃          manifest.json        171 bytes                                                                │
│  ✔     ᠃          entrypoints.json     162 bytes                                                                │
│  ✔     ᠃          wordpress.json       33 bytes                                                                 │
│                                                                                                                 │
│                                                                                                                 │
 duration    72s 378ms (22s 826ms + 49s 552ms)

 mode    production    hash       ae5ae51fbdbb41f02e06
 bud     5.7.6         webpack    5.70.0

[99%] [cache] shutdown

Done in 110.33s.

One thing that’s interesting is your overall build duration shows that literally the entire build is slow:

72s 378ms (22s 826ms + 49s 552ms)

The first parenthetical number (22s) is bud’s pre-compilation timing. The second (49s) is the actual webpack compilation. In relation to one another, these two numbers seem about right (without caching bud takes about 1/2 the time webpack does).

Once bud has passed the config to webpack it’s pretty much done (when running bud build, at least). So, it’s like an across-the-board slowness. It doesn’t seem like there is a hotspot to debug.

So, my next question: is there any type of throttling happening? There are two key differences between mix and bud which may be relevant here, in my mind:

  • mix is almost 100% synchronous while bud is almost 100% asynchronous
  • bud writes to disk a great deal more than mix does

If you have a system monitoring utility you can tap in the context of the VM I wonder what the disk and RAM usage looks like…