postcss / postcss-url

PostCSS plugin to rebase url(), inline or copy asset.
MIT License
377 stars 59 forks source link

add dependency message support #95

Closed clydin closed 7 years ago

clydin commented 7 years ago

This adds support for postcss's dependency messaging and allows postcss runners that support file watching to account for any inlined or copied files.

michael-ciniawsky commented 7 years ago

@ai Who is current maintainer here ? 😛 This is likely needed for postcss-loader in the future in one way or the other (didn't check the PR yet), since css-loader will drop url() resolving in v1.0.0 aswell as it seems atm. This change is 👍 in general, I can 'help' with it if needed :)

clydin commented 7 years ago

Supporting postcss-loader and allowing it to handle url()'s instead of css-loader is indeed the primary goal of this PR.

michael-ciniawsky commented 7 years ago

@clydin Did you try your branch of postcss-url + postcss-loader?. Any insights upon this are highly welcome 😛 , but I guess it will require more to get it working (postcss-loader Interface)

ai commented 7 years ago

I think @MoOx is maintainer. And he will be happy if somebody will take maintainer role.

sergcen commented 7 years ago

@michael-ciniawsky @ai i already take it

sergcen commented 7 years ago

@michael-ciniawsky @clydin i didn't check PR, but i understand the problem. I will check it soon

michael-ciniawsky commented 7 years ago

@sergcen 👍 No rush at all, I just started to investigate for postcss-loader into the url() related parts and was delighted to see the main 'plugin part' already done here 💯 😛

clydin commented 7 years ago

Since postcss-loader already handles the dependency message, both inline and copy work. Note that the copy action handles the actual copying to output so file-loader/URL-loader are not needed/used. Something to consider is whether an additional message and/or postcss-URL action would be useful to allow postcss-loader to inject the file as an asset. Definitely a subject for a separate PR though.

michael-ciniawsky commented 7 years ago

Something to consider is whether an additional message and/or postcss-URL action would be useful to allow postcss-loader to inject the file as an asset.

That's an interesting idea 😛 I will make a note 🙃

Since postcss-loader already handles the dependency message, both inline and copy work. Note that the copy action handles the actual copying to output so file-loader/URL-loader are not needed/used.

Yeah, when these two 'suckers' are envolved, it gets fairly tricky to resolve url()'s, since they need a 'special' placeholder ___PostCSS__LOADER__URL__(${index}) to work and url(./path/to/file.png) needs to be 'requestified' => url(require(___PostCSS__LOADER__URL__${index})), but I will open an issue about this in postcss-loader soon, so let's not spam the PR here further 😛