Hi, I'm writing a plugin for vite to load rust/wasm. I want to access build configurations, assetsDir, root, publicBase, etc. I can resolve those from command line arguments. But that require the same same processing as vite, which would not be duplicate and not optimal. If would be useful it vite provide api to get this ResolvedConfig.
After this pr, you can use await resolveConfig() to get the config:)
When vite build is used, your plugin can define configureBuild to access the Vite config (and even mutate it).
configureBuild(config) {
console.log(config.root)
}
BuildContext objectWhen #1015 is merged, the argument should be renamed to ctx (since a BuildContext object will be passed), but the Vite config is still accessible through that. The assetsDir and outDir will be absolute paths, so you won't need to resolve them manually anymore (eg: path.resolve(config.root, config.outDir, config.assetsDir)).
What happened to resolveConfig api mentioned earlier? It's recommended to do use configureBuild now?
@gliheng I could see resolveConfig being useful to plugins that need the Vite config outside a configureBuild hook. I think we're waiting on approval from @yyx990803 before merging #740 (and it's still a draft PR for some reason).
Most helpful comment
After this pr, you can use
await resolveConfig()to get the config:)