Plugins with multiple builds clobber each other #15537
-
Describe the bugI have a custom plugin that handles the main build (multiple entires with chunking, etc). I would like to also perform a second [lib] build that compiles each [different from build 1] entry into a single output file, and also places them in the final dist location (though different subfolder) that the first build outputs to. Note that both builds have very different build configs. If my plugin uses its own plugin for build 2 it results in one clobbering the other. Fortunately, we have our own build executable so I can get around this by doing:
The downside with my workaround is that any config sent to my plugin is inaccessible to my second build since it's not actually using my plugin that users would add to their vite.config.js. Ideally, I could write a plugin that has a multi-step build process that executes in a defined order. Tangentially, would love to see this issue get some love. The workaround is to perform a build per entry like described here. ReproductionN/A Steps to reproduceNo response System InfoSystem:
OS: macOS 12.6
CPU: (10) arm64 Apple M1 Max
Memory: 764.28 MB / 64.00 GB
Shell: 5.2.21 - /usr/local/bin/bash
Binaries:
Node: 18.18.2 - ~/.nvm/versions/node/v18.18.2/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 9.4.1 - /opt/homebrew/bin/npm
pnpm: 8.8.0 - /opt/homebrew/bin/pnpm
Browsers:
Chrome: 120.0.6099.199
Safari: 16.4.1
npmPackages:
@vitejs/plugin-react: ^4.2.1 => 4.2.1
vite: 5.0.9 => 5.0.9 Used Package Managernpm LogsNo response Validations
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
SvelteKit is able to run continuous builds within Vite plugins like so: https://github.com/sveltejs/kit/blob/2a302b26d6f8c9d46c59852c3f8f25e387e30876/packages/kit/src/exports/vite/index.js#L659-L664 I think you could do something similar to achieve that too? |
Beta Was this translation helpful? Give feedback.
SvelteKit is able to run continuous builds within Vite plugins like so: https://github.com/sveltejs/kit/blob/2a302b26d6f8c9d46c59852c3f8f25e387e30876/packages/kit/src/exports/vite/index.js#L659-L664
I think you could do something similar to achieve that too?