rollup-plugin-postcss: 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
I’m getting an error when I try to define a filename for the extract option.
postcss({
extract: 'dist/test.css',
…
})
v2.4.0:
[!] (plugin postcss) 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 “…/test.css”.
Works on v2.3.0.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 43 (3 by maintainers)
This comment by @lukastaegert provides the full solution. What I had to do was:
This works perfectly.
I’ve done this workaround using
rollup-plugin-copy
androllup-plugin-delete
It has not been fix this issue for 100 years
Same for me with v2.8.2, I’m getting the error with this snippet in my rollup.conf
The issue should be re-opened until fixed no?
@evdama @jhoffmcd
Unless I’ve misunderstood what you need, the quick fix is to use a path like
static/output.css
in theextract
option, rather than./static/output.css
(with a.
). It’s resolved relative to theoutput.dir
set in the main rollup config.If you want to use a relative path (e.g. outside of the
output.dir
), that’s not officially supported by the rollup emitFile API, which this plugin uses. When I was playing around directly with emitFile API though, I did have success using a file path likenotarealfolder/../../outsideOfOutputDir.file
.I’ve not tried this for rollup-plugin-postcss, but if that suits your use case, it might be worth giving it a go.
I came here with the hope of seeing this being fixed, and yet after 2 years still not fixed, unbelievable!!!
Here is my config and yet didn’t work;
As per the config above, added the “dist” directory with the hope of producing a single stylesheet for both ESM and CJS but not lucky, instead, both ESM and CJS ended up with their own stylehseet.css but in a nested folder, the “dist”, like so;
This is absolutely shocking!
Another thing that works to copy to the correct path is using rollup-plugin-copy:
Thank you! It almost solved it. Previously I had more control on where the outputted file goes. Now it seems to be created in
output.dir
, which in my case I have multiple;dist/esm
anddist/cjs
. Before I could output the CSS file indist/bundle.css
, now it’s created in those output folders.I tried passing
extract: '../bundle.css'
but that didn’t work.I have just tried 4.0.2 which is the latest version at the moment and it is still broken. Any plans to fix this issue?
Hi @evdama that’s now separated and this template is now using svelte-preprocess instead of compiling postcss with rollup-plugin-postcss. Take a look at https://github.com/nhristov/sapper-template-rollup/blob/master/rollup.config.js.