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
Rebasing URL's doesn't work for certain situations #1033
Comments
Could be related to #1029. |
Won't fix as clean-css is going into maintenance mode. |
@jakubpawlowicz Thanks for your work here, You built a great tool. According to the readme, CleanCSS could receive occasional bug-fixes. Shouldn't this qualify? Currently, the |
Hey @binyamin. It depends if anyone is able to suggest an easy solution to this, and I am not sure if there's any. @chris-monahan suggested "take the file component and stick it on the end of a fixed path" and that could be an easy solution, perhaps even via a plugin instead of a change to clean-css itself. Is it something that would work for you? |
@jakubpawlowicz Yes, I think so. You could even normalize the path afterward, using |
I will reopen it but I don't have capacity to fix it, so PRs are more than welcome. Idea - clean-css v5+ has a plugin interface, so I wonder if it's doable via a plugin instead. |
I am trying to use clean-css in order to bundle CSS from a variety of sources including Font-Awesome. In order for these to work then I need to import the web fonts.
The default rebase is not what I want because the original CSS url's reference the original files in ./node_modules which will not be distributed in the final package. Instead the font-files have been copied to another directory (/dist/fonts/). By setting {'rebase': false} I can nearly get what I want however now the original relative paths of e.g "../fonts/fontawesome-webfont.woff?v=4.7.0" now don't work for us.
In order to get them to work I can see two real options.
While this will work for this specific instance it is messy and is completely dependent on how the original package was structured. We are ceding control of how our files are arranged to third party libraries, and there is no guarantee they will even be consistent. (I.e. this will only work because font-awesome uses ../fonts/ as their source directory. If another library used something else, we would need to use that).
If necessary this will be what I try next. While I think this will work for us it seems like an approach that could get unnecessarily complex and brittle when you start dealing with things like CSS urls in other contexts and in more complex properties etc. I would rather a better solution.
Seems like this is something that should be possible in CleanCSS - an ability to rewrite URL's in some way other than relative rebasing. A simple absolute prefix would work for us, where you say "take the file component and stick it on the end of a fixed path", but as this could be more complicated I could see there being value in having some more flexibility. Perhaps a way of limiting absolute paths to only certain properties, or a callback to filter URL's like what is currently used for arbitrary property transformations, except specifically for URL's and handling some of the complexity for you.
Environment
npm ls clean-css
: clean-css@4.1.11node -v
:v8.11.0Configuration options
The text was updated successfully, but these errors were encountered: