Way to import any SCSS files from multiple folders in bud.config.mjs?

I would skip setting a path for this. The simplest version is probably:

app.entry({blocks: ["views/blocks/*.{css,scss}"]})

That’s using fast-glob syntax to restrict the wildcard to matching filetypes. I don’t think you can mix path aliases and wildcards (at the very least I can say we don’t have any tests set up for that). So, just express the path relative to to resources as a string, and bud should take it from there.

You have to restrict the filetypes since you have php files in that directory. bud doesn’t know what a php file is.

Alternative: globbing

You could glob for assets:

async

await bud
  .glob("@views/blocks/*.{scss,css}")
  .then((stylesheets) => bud.entry("blocks", stylesheets));

sync

app.entry({
  blocks: app.globSync("@views/blocks/*.{scss,css}"),
})

bud.assets

assets(["images","views/blocks/**/*"]) 

… seems to load php files and everything into the compilation.

If you are just trying to include scss this isn’t the function you want. These files will not be processed with sass – just copied.

For the benefit of other readers, if I were trying to glob for files rather than just copy a directory, similar to the above attempt, I would specify the task with an object:

app.assets({
  from: app.path("@images/*.svg"),
  to: app.path("@dist/images"),
})
2 Likes