Closed weaverryan closed 5 years ago
@weaverryan and others, any news on this?
We'd love to build multiple bundles into the "same" output directory like visualized below. We can't output all files in the build/
directory since the directory gets cleared before compiling and we want to be able to compile the bundles separately.
web
- build
- admin // separate admin build
- app // separate app build
You've stated safety as a reason. Maybe we could allow a maximum of 3 levels of directories to be created before the outputPath directory does not exist
error gets thrown? Another option might be comparing the base path of the Encore installation (e.g. via require.main.filename
or something similar) to the outputPath
to make sure it at least gets created within the project?
I could submit a PR for this if you're interested. Let me know!
I have the same problem, Do you have a workaround?
@h3llr4iser By "same problem" do you mean having multiple build folders? Couldn't you just call cleanupOutputBeforeBuild()
with multiple paths?
For instance:
// First build
Encore.cleanupOutputBeforeBuild(['admin/**/*']);
// Second build
Encore.cleanupOutputBeforeBuild(['app/**/*']);
Currently, we do create the output directory if it does not exist... but we only go one level deep (if
web/
exists, we will createweb/build
, but ifweb
does not exist, we throw an error): https://github.com/symfony/webpack-encore/blob/799720602aab2069f827704e4a6d672d03d38d76/lib/WebpackConfig.js#L107We do that for safety, but in this (rare) situation, it's kind of annoying. My friend Beau hit it recently with Encore on Sculpin :).