2

I need to output multiple .js files based on locale for my project. Is this possible? Would I have to have multiple vite.config.js files and build them separately?

To bundle I use npm run build which bundles into a dist folder.

If I could build separately, my thought is that each file would have something like this, but the input path would change, and ouput file name would too per country/locale.

ex file 1

rollupOptions: {
            input: {
                index: "./src/en_US/sitemap.js",

            },
            output: {
                entryFileNames: "sitemap-en-us.js",
            },
        },

ex file 2

rollupOptions: {
            input: {
                index: "./src/en_CA/file.js",

            },
            output: {
                entryFileNames: "file-en-ca.js",
            },
        },

but how would i configure having 2 vite.config.js files?

OR, can I set up having mulitple inputs with multiple outputs? Can I have index1, index2 with multiple entry points assigned to each input?

  • Have a look at https://stackoverflow.com/questions/74390015/how-to-do-multiple-bundles-with-vite Seems to be the best Vite can do atm – Moritz Ringler Feb 07 '23 at 18:42

1 Answers1

-1

You can create 2 vite config files, then run vite build -c us.config.js && vite build -c ca.config.js

kurama
  • 41
  • 6