How to output multiple bundles
johannes-z opened this issue · comments
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',
]
I'm having a similar issue, I can't seem to find a clear way to configure output directories relative to the individual inputs...?
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"
}
]
}
@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.