clean-css-cli icon indicating copy to clipboard operation
clean-css-cli copied to clipboard

The behaviour of rebasing URLs when an output is given should be overwriteable

Open Lenni009 opened this issue 2 years ago • 1 comments

You sometimes don't want to rebase the URLs, for example when everything stays in the same directory. So if I previously had a folder src/css/ and in it a file with this CSS:

@import 'fonts.css'

clean-css-cli does this:

@import 'src/css/fonts.css'

Now the style breaks because there is no adjacent src folder to the CSS file.

On the contrary, this would be fine (added slash in front of path to make it absolute):

@import '/src/css/fonts.css'

Solutions:

  • Either fix the rebase algorithm to add a / to the rebased URL to make it absolute
  • Give the user an option to overwrite this behaviour. I tried version 4.3, which still had --skip-rebase enabled, and that worked (but threw a bunch of other errors/warnings, so can't use it in prod)

Lenni009 avatar Mar 22 '23 22:03 Lenni009

This also happens without the output flag, the imports are always made to be absolute.

Lenni009 avatar Mar 22 '23 23:03 Lenni009