Replies: 1 comment
-
Figured out a way, but I doubt it's the most elegant. I set up a custom transformer plugin to add any const { Transformer } = require('@parcel/plugin');
const { glob } = require('glob');
const { join } = require('path');
const BASE = join(__dirname, '..', 'public'); // 'public' is the name of my src folder
const MAIN_INDEX = join(BASE, 'index.html');
module.exports = new Transformer({
async transform({ asset }) {
if (asset.filePath === MAIN_INDEX) {
const paths = glob.sync('**/index.html', { cwd: BASE })
.map(x => x.replace(BASE, ''))
.filter(path => path !== 'index.html');
paths.forEach(path => {
asset.addDependency({
id: path,
specifier: path,
isEntry: true,
});
});
}
return [asset];
},
}); Then added config: {
"transformers": {
"*.html": [
"parcel-transformer-add-html", // name of above package
"..."
]
},
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have an HTML file on my site that is not linked to anywhere, but I still want to include it in the build. Is there a way to tell Parcel that I want to include it? Or alternatively, is there a way to disable unused files being removed, either for just HTML files or for all files?
Beta Was this translation helpful? Give feedback.
All reactions