-
-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
{mode: 'extract'} without css modules #117
Comments
Hello again @dilyanpalauzov, thanks for another contribution!
My bad, now that I read it again I understand that it is misleading,
Yes, I'm aware of that, and currently working on it (in fact the hash augmentation part is already there).
Yep, this is a bug, thanks for finding this. I'll change it to being relative to output directory (also this is a breaking change, so it will be v3), or I will add an error which warns about resulting path being outside of dist dir if Rollup's
It is intended, since this is meant for later plugins in the build pipeline, so it doesn't generate JS wrapper, keeping chunk pure CSS, which makes Rollup angry since it does not understand it. But yeah, this should be better documented, so will do. Also with that in mind, it is hard to produce a proper example, but i'll think of something. |
I've released v3, hopefully it fixes all the problems you listed and more, check it out and let me know |
With version 3.0.2, I set rollup-plugin-styles does find the files referenced by url(relative-paths) in the .css sources and moves them to the output directory (dist). The resulting .ccs file is correctly located and called dist/t/e-[hash].css . But the other assets are under the dist/assets/assets folder. Moreover, t/e-[hash].css contains now the relative urls as |
Well, this is kinda intended, because at first i planned for both CSS assets and assets from CSS URLs
I believe either |
Ok, |
Alright. Now, when the output.assetFIlenames is not changed, and stays But when I change output.assetFIlenames then assets extracted form url()-css do to respect the new output.assetFileNames. This is not a big issue, but would be nice, if the assets coming from rollup-plugin-styles honours output.assetFileNames. Moreover, the default for output.assetFileNames is "assets/[name]-[hash][extname]", but https://github.com/Anidetrix/rollup-plugin-styles/blob/master/README.md recommends changing it to |
It would be, but as I said this is pratically impossible since
True, clarified the documentation there, thanks. |
Do I understand you correctly, that the css-url() assets are inserted with this.emitFile(type:'asset', name) during the transform hook and emitFile ignores the output.assetFileNames option when called from.transform()? If this is a deficiency in rollup, do you want to report it? The rollup website does not say anything about ignoring outpu.assetFileNames from transform(). |
No, that's not it. You can call |
My understanding is that, if assets are injected during the transform() hook with Why are the filenames of the assets needed before |
Correct, although there are hooks before
First off, URLs are being modified right away, but it is theoretically possible to modify them during |
So during the transform() phase the url() assets need to be put on the right place without knowing the output.assetFileNames value. And putting the assets later on the right place can work for mode:extract, but not for modes “inject” or “emit”. The description of "inject":
I would clarify further this description, stating that the CSS is embedded in the generated JS files and the JS files at runtime extend <head>. Fair enough. Althougt |
https://github.com/Anidetrix/rollup-plugin-styles/blob/master/README.md says:
“Note that, by default, generated CSS will be injected into <head>, with CSS also available as default export unless CSS Modules are enabled,”... “CSS Modules styles({ modules: true,})”
This means, that CSS Modules are enabled with modules:true and unless the modules are enabled, the css will be injected into head.
It turns out, that style({mode:'extract'}) prevents the automatic injection.
mode:'extract' changes just the file extensionof the entryfilename, but I want to use as name something that contains the hash of the css-content and ideally honours the https://rollupjs.org/guide/en/#outputassetfilenames option.
With style({mode:['extract':'dist/[hash]-e.css']}) the file is called literally [hash]-e.css
With style({mode:['extract':'e.css']}) rollup receives '../e.css' and says the filenames cannot be relative or absolute.
With mode:'emit' I get:
! Error: unexpected token (Note that you need plugins to import files that are not JavaScript)
xxx/zzz.css:
(css code)
• The mode:['extract', 'SECOND-ELEMENT'] shall honour output.dir and be just file without path.
• The generated file shall honour the output.assetFileNames pattern, possibly inserting its own hash in the filename.
• Please elaborate in the documentation how mode:emit is supposed to be used
The text was updated successfully, but these errors were encountered: