Is it possible to have multiple (array) input/output options in rollupOptions for Vite?

817 Views Asked by At

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?

1

There are 1 best solutions below

0
kurama On

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