Is there a way to have multiple file entry points build out to a destination relative to the entry point? Currently all I could find is a single destination folder.
If you had something like the following structure given the entry point below, is there a way to have it build the JS into a destination folder that's next to each src folder? So you would end up with dist in subfolder1 and subfolder2. I was looking at the API but it doesn't seem that there's a way to
Entry Point: ./app/**/src/*.js
.
โโโ app
โโโ subfolder1
โ โโโ src
โ โโโ some.js
โโโ subfolder2
โโโ src
โโโ another.js
โโโ some-more.js
Expected
.
โโโ app
โโโ subfolder1
โ โโโ dist
โ โ โโโ some.js
โ โโโ src
โ โโโ some.js
โโโ subfolder2
โโโ dist
โ โโโ another.js
โ โโโ some-more.js
โโโ src
โโโ another.js
โโโ some-more.js
Another Possible Outcome:
.
โโโ app
โโโ subfolder1
โ โโโ some.js
โ โโโ src
โ โโโ some.js
โโโ subfolder2
โโโ another.js
โโโ some-more.js
โโโ src
โโโ another.js
โโโ some-more.js
Maybe there could be an option with the API to get the current directory of the current file and then you could explicitly set an output path.
Nope.jpg
Maybe something in a custom API build like:
const options = { output: fileIn => `${fileIn}/../someDirectory` };
new Bundler(entryFiles, options);
For the CLI maybe you could just have a relative-output option so you could specify ` --relative-output ./../someDirectory
| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 1.11.0 |
| Node | v11.1.0 |
| npm/Yarn | 6.7.0 |
| Operating System | Mac OS |
Here's my current implementation to handle this for now.
const Bundler = require('parcel-bundler');
const buildType = process.env.BUILD_TYPE || 'build';
const bundleDefaults = {
watch: buildType == 'watch',
contentHash: false,
minify: false,
sourceMaps: false, // only because inline maps are not supported yet.
hmr: false
}
const subfolder1Bundle = {
entryFiles: 'app/subfolder1/src/*.js',
options: {
...bundleDefaults,
outDir: 'app/subfolder1/src',
}
};
const subfolder2Bundle = {
entryFiles: 'app/subfolder2/src/*.js',
options: {
...bundleDefaults,
outDir: 'app/subfolder2/src',
}
};
const bundles = [
subfolder1Bundle,
subfolder2Bundle
];
(async function() {
// forEach will run in parallel
bundles.forEach(async bundle => {
// Initializes a bundler using the entry point location and options provided
const bundler = new Bundler(bundle.entryFiles, bundle.options);
// Run the bundler, this returns the main bundle
// Use the events if you're using watch mode as this promise will only trigger once and not for every rebuild
await bundler.bundle();
});
})();
@ctsstc it's great solution until you will use shared resources (svg/images) and they'll be just duplicated for each bundle with own name :(
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs.
Most helpful comment
@ctsstc it's great solution until you will use shared resources (svg/images) and they'll be just duplicated for each bundle with own name :(