Output multiple files using Rollup
Asked Answered
G

3

14

I am using Rollup to bundle my code for production.
I have multiple js files, so I am using the Rollup plugin-multi-entry plugin to use a glob pattern to target all of my js files.
I am outputting the files in umd format.

Currently they are being output as one js file, bundled all together, this is the expected behavior, but I would like to out put them all individually as well, transpiled to es5 and in umd format but not concatonated into one js bundle file, how can I do this?

Current setup:

import babel from "rollup-plugin-babel";
import { terser } from "rollup-plugin-terser";
import multi from "@rollup/plugin-multi-entry";
import gzipPlugin from "rollup-plugin-gzip";

export default [{
    input: "src/**/*.logic.js",
    output: {
        dir: "build/assets/js",
        format: "umd",
        name: "Logic"
    },
    plugins: [
        gzipPlugin(),
        multi({
            exports: true
        }),
        babel({
            exclude: "node_modules/**"
        })
    ]
}]
Gerfen answered 1/10, 2020 at 14:2 Comment(1)
It looks like this plugin can come to help github.com/alfredosalzillo/rollup-plugin-multi-inputCorrespond
F
9

https://rollupjs.org/guide/en/#configuration-files

Here's an example:

export default [
  {
    input: 'main-a.js',
    output: {
      file: 'dist/bundle-a.js',
      format: 'cjs'
    }
  },
  {
    input: 'main-b.js',
    output: [
      {
        file: 'dist/bundle-b1.js',
        format: 'cjs'
      },
      {
        file: 'dist/bundle-b2.js',
        format: 'es'
      }
    ]
  }
];
Folger answered 9/9, 2022 at 6:51 Comment(0)
P
0

You should able to do that with Rollup without any plugins.

Take a look at the code splitting section from their documentation.

Patrilocal answered 15/6, 2022 at 11:47 Comment(0)
L
0

If you want multiple builds, have multiple vite config files and run vite build -c different.config.js

Lasley answered 9/8 at 10:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.