-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Description
Describe the bug
I have a plugin that post-processes the built files for i18n using the generateBundle hook, but in recent Vite versions it runs before Vite replaces the VITE_PRELOAD strings.
The importanalysis plugin always runs after user defined plugins:
vite/packages/vite/src/node/plugins/index.ts
Lines 99 to 108 in 6f8a320
| ...postPlugins, | |
| ...buildPlugins.post, | |
| // internal server-only plugins are always applied after everything else | |
| ...(isBuild | |
| ? [] | |
| : [ | |
| clientInjectionsPlugin(config), | |
| cssAnalysisPlugin(config), | |
| importAnalysisPlugin(config), | |
| ]), |
The reason I picked generateBundle is so that I don't have to worry about where the files are stored. writeBundle doesn't get called when using the API and closeBundle doesn't seem to have the information to find the built files.
Should there be one more plugin hook, e.g. bundleComplete? Or should I be doing the post-processing differrently?
Reproduction
Steps to reproduce
Use compiled-i18n in a project, bundle it, and notice that VITE_PRELOAD is still present in the i18n-ed versions.
System Info
System:
OS: Linux 6.1 NixOS 24.05 (Uakari) 24.05 (Uakari)
CPU: (8) x64 Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz
Memory: 3.73 GB / 15.20 GB
Container: Yes
Shell: 5.2.26 - /run/current-system/sw/bin/bash
Binaries:
Node: 20.9.0 - /nix/store/a1hckfqzyys4rfgbdy5kmb5w0zdr55i5-nodejs-20.9.0/bin/node
npm: 10.1.0 - /nix/store/a1hckfqzyys4rfgbdy5kmb5w0zdr55i5-nodejs-20.9.0/bin/npm
pnpm: 8.15.0 - ~/bin/pnpm
npmPackages:
vite: ^5.1.5 => 5.1.5Used Package Manager
pnpm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.