Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to output multiple bundles #268

Open
johannes-z opened this issue Dec 4, 2019 · 3 comments
Open

How to output multiple bundles #268

johannes-z opened this issue Dec 4, 2019 · 3 comments

Comments

@johannes-z
Copy link

If I have a config with an array of entry points (each of which have the same file name), how can I create multiple bundles?

The following example would output index.js twice, so the second bundle overwrites the first one...

input: [
  'src/project-a/index.ts',
  'src/project-b/index.ts',
]
@myarete
Copy link

myarete commented Apr 15, 2020

I'm having a similar issue, I can't seem to find a clear way to configure output directories relative to the individual inputs...?

@johannes-z
Copy link
Author

extendRollupConfig gets called for each input entry (if it's any array). I created an array with all the required information (path to the index file, amd-id, output filename), and use a global index variable:

import { Config } from 'bili'

import _config from './config.json'

let index = 0
const config: Config = {
  input: _config.bundles.map(bundle => bundle.entry),
  output: {
    format: 'amd-min',
    fileName: '[name][ext]',
    target: 'browser',
    sourceMap: false,
  },

  extendRollupConfig: config => {
    const bundle = _config.bundles[index++]
    config.outputConfig.entryFileNames = bundle.dist
    config.outputConfig.amd = {
      id: bundle.dist,
    }
    return config
  },
}

config.json looks like this:

{
  "bundles": [
    {
      "entry": "src/project-a/index.ts",
      "dist": "projecta.js"
    },
    {
      "entry": "src/project-b/index.ts",
      "dist": "projectb.js"
    }
  ]
}

@StarpTech
Copy link

StarpTech commented May 22, 2020

@johannes-z great workaround but this looks horrible. Yesterday I setup rollup manually with this feature and it took me 1 hour to compile my libs without Bili. It would be awesome to contribute to Bili but the maintenance is very low. It would be great to hear more feedback from the creators.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants