'How can I allow JSON files to not be bundled in vite
I am doing work on my vite project with i18n and that means json files. I am wanting to figure out how I can swap out JSON files after the build has been run. Currently our json files are getting pushed into the bundle and I would like that to at least appear as a separate chunk instead of being bundled with our JS files. Tried a few different approaches and seem unable to get it to work. Any tips or tricks would be awesome.
Solution 1:[1]
According to the Static Asset Handling documentation in vite, you can create a directory named "public" in the root of your vite project. After creating that directory, there, you can create the "locales" directory where you would put your translation files.
See the image for implementation reference: vite project structure
Also, if you are using the "i18next-http-backend" package to load the files asynchronnously it will default to that route, so the i18next initial configuration would look like this:
i18next.use(Backend)
.use(LanguageDetector)
.init({
fallbackLng: "en",
debug: true,
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | DGVIP |
