I'm using https://shoelace.style (in my Svelte project), and following the example config in shoelace docs, I added a copy()
plugin to my rollup.config.js
, copying it to public/vendor/shoelace
:
export default {
// SNIP
plugins: [
// SNIP
copy({
targets: [
{
src: path.resolve(
__dirname,
"node_modules/@shoelace-style/shoelace/dist/assets"
),
dest: path.resolve(__dirname, "public/vendor/shoelace"),
},
],
}),
// SNIP
],
};
It works, but now the build takes really really long - upwards of 40s, including incremental rebuilds on file change. I am fairly sure the time loss isn't because it's accidentally copied every time, as the asset folder is just 6M.
So, I suppose there's some tree-shaking and/or optimizations going on? Is there way to exclude the folder from rollup processing - or to troubleshoot/profile the bundling process anyhow?
(If necessary, I can also post the rest of the config; but it's otherwise standard new app template obtained by npx degit sveltejs/template
and adding/removing the copy plugin made all the difference.)
The issue turned out to be in the rollup-plugin-copy
. Even setting copyOnce: true
did not change the behavior, but setting it so that it only copies at the last possible opportunity - the closeBundle
hook fixed my problem.
copy({
copyOnce: true, // ???
hook: "closeBundle",
targets: [
{
src: path.resolve(
__dirname,
"node_modules/@shoelace-style/shoelace/dist/assets"
),
dest: path.resolve(__dirname, "public/vendor/shoelace"),
},
],
}),