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

Outputting codeSplitting bundles into subfolders relative to output.dir #2216

Closed
maranomynet opened this issue May 24, 2018 · 4 comments
Closed

Comments

@maranomynet
Copy link
Contributor

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
@guybedford
Copy link
Contributor

guybedford commented May 24, 2018

@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.

@maranomynet
Copy link
Contributor Author

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.

@maranomynet
Copy link
Contributor Author

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

@Hashbrown777
Copy link

Hashbrown777 commented May 23, 2021

Unfortunately with that approach ( @guybedford ) all sourcemaps declared in the output aren't nested (original problem).

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