Skip to content
This repository has been archived by the owner on Oct 9, 2020. It is now read-only.

CSS URL prefix option #52

Closed
guybedford opened this issue Jul 15, 2015 · 8 comments
Closed

CSS URL prefix option #52

guybedford opened this issue Jul 15, 2015 · 8 comments

Comments

@guybedford
Copy link
Member

When bundling, URLs in CSS files are output as baseURL-relative. It can be worth having an option to set a custom prefix here - say System.clientBaseURL or something like that to inject during the build.

Perhaps the simplest is just to call it basePrefix?

Getting the name right is probably the hardest part.

@jamesgorrie
Copy link

Isn't it already applying the baseURL when clean-cssing? When testing it - it seems to, but the URL is still mismatched.

@guybedford
Copy link
Member Author

Client and build baseURLs are separate things, so we need to take both into account for the final URL.

@jamesgorrie
Copy link

Ah, I see.

As, while you're developing - the client baseURL is going to be used - surely it makes sense to keep them as one? Unless perhaps you wanted to have your prod environment use a different path to your dev, but it might be worth waiting for that use case?

Do you think it'd be too coupled to just pass the baseURL through here as a default?

@guybedford
Copy link
Member Author

The client baseURL is a browser URL relative to the browser public folder root. The server baseURL is a server path relative to the package.json to the same folder. Understanding that distinction is important to know how builds work - it should be better documented I know.

@theefer
Copy link

theefer commented Jul 21, 2015

I have tried a variety of clean-css options but I can't seem to find a way to inject an absolute (or even relative) prefix to all image URLs. Docs seem to hint at using a combination of relativeTo and root but I can't seem to find the right combination...

@guybedford
Copy link
Member Author

Ideally we should upgrade this plugin to use PostCSS. Help managing this plugin would be incredibly welcome.

@theefer
Copy link

theefer commented Aug 24, 2015

Could you elaborate on what you see us use PostCSS for in this plugin? Just rebasing URLs to allow a prefix? Replacing some of the work clean-css does? Would it become more of a (hardcoded for now) post-processing pipeline?

@guybedford
Copy link
Member Author

It seems like a better base project to use here than CleanCSS for providing more flexibility around the re-normalization of CSS process, and having the clean css process as a transformer on top of that. Then yes it does open the door to a processing pipeline as well, which would be nice to offer to users via meta-configuration of css transformers.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants