Svelte uses Rollup for bundling. This is the folder structure.
svelte/
├── node_modules/
├── public/
│ ├── bundle.js
│ └── bundle.css
├── src/
│ ├── App.svelte
│ └── main.js
└── rollup.config.js
I want to save both the bundle.js and bundle.css outside the root folder.
Here's the rollup config.
input: "src/main.js",
output: {
format: "cjs",
name: "app",
file: "../../src/svelte/bundle.js",
},
plugins: [
svelte({
css: (css) => {
css.write("/bundle.css");
},
}),
],
I can save the bundle.js fine, but the path passed to css.write() for bundle.css is relative to the bundle.js destination directory.
If I try to do css.write("../bundle.css"), I get this error...
Error: The "fileName" or "name" properties of emitted files must be strings that are neither absolute
nor relative paths and do not contain invalid characters, received "/bundle-svelte-activities.css".