I don’t have a great grasp of Bud’s internals, so I can’t speak to the reasoning behind this decision or if there’s a simpler way to modify it, but the Bud docs mention a way to bypass the assets()
API if you want:
// This doesn't appear to return a chainable object, so add it after your initial definition.
app.extensions.get('copy-webpack-plugin').setOption('patterns', [
{
from: app.path('@src/images'),
},
]);
I tested this locally with a fresh Sage install, and it didn’t flatten assets into a single folder, i.e.:
resources/
images/
image-1.jpg
subdir/
image-2.jpg
Resulted in:
/public
image-1.jpg
/subdir
image-2.jpg
If you wanted to dig into the reasons for this, the bud.assets code is here: bud/assets.method.ts at 9bd07900c5b98b00b835d53e1dcd4a17e6ee5c1b · roots/bud · GitHub
This provides some context for why webpack is (probably) flattening the dirs: GitHub - webpack-contrib/copy-webpack-plugin: Copy files and directories with webpack