Rollup: Outputting codeSplitting bundles into subfolders relative to `output.dir`

Created on 25 May 2018  路  3Comments  路  Source: rollup/rollup

When using the experimentalCodeSplitting and output.dir options - is it somehow possible to maintain the relative folder structure of the input files - or somehow direct the output of individual bundles relative to output.dir?

With this config:

export default {
    input: [
        'src/module1.js',
        'src/foo/module2.js',
        'src/foo/bar/module3.js',
    ],
    experimentalCodeSplitting: true,
    output: {
        format: cjs,
        dir: 'dist'
    }
}

What I get is this flat structure:

dist/module1.js
dist/module2.js
dist/module3.js

but I'd like this:

dist/module1.js
dist/foo/module2.js
dist/foo/bar/module3.js

Most helpful comment

well, I guess output.dir could also accept a inputFile->outputFile mapping function

All 3 comments

@maranomynet you can name the input files with:

export default {
    input: {
        'module1': 'src/module1.js',
        'foo/module2': 'src/foo/module2.js',
        'foo/bar/module3': 'src/foo/bar/module3.js',
   },
    experimentalCodeSplitting: true,
    output: {
        format: cjs,
        dir: 'dist'
    }
}

it could well be worthwhile to have an option for this - I've wondered if we need an inputNameBase or something like that, where the default can be false implying basenames only. Just have to be super careful with all this stuff to try and make it relatively intuitive.

Ah, wonderful! thank you.

But the documentation for the input option does not convey this information very clearly.
Not in a million years would I have guessed this was what it meant.

I'd rewrite it and make a pull request, but I feel like I don't understand this well enough to document it correctly.

well, I guess output.dir could also accept a inputFile->outputFile mapping function

Was this page helpful?
0 / 5 - 0 ratings

Related issues

good-idea picture good-idea  路  3Comments

FruitieX picture FruitieX  路  3Comments

adammockor picture adammockor  路  3Comments

iam-peekay picture iam-peekay  路  3Comments

nanomosfet picture nanomosfet  路  3Comments