postcss / postcss-url

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

Correct path resolution when to/from paths match #136

Closed bcomnes closed 4 years ago

bcomnes commented 4 years ago

If you want to run post-css on the following arrangement:

postcss app/app.css -o app/app.bundle.css

Postcss-url will then save the copied assets to process.cwd(), which in this case is .. Not correct. It should copy the assets to ./app/${assetsPath}.

This fix makes it so the assets are correctly copied to the same folder (presumably inside of a assetsPath) when a to option exists. Otherwise, use the old cwd() behavior.

I'm not 100% sure what the intention of the original logic was, but it appeared to be guarding for when there was a missing to option. This will still preserve the original behavior when to is !existy and use process.cwd(). Apologies if this understanding is incorrect.

bcomnes commented 4 years ago

🎉🙏TY! I can float off the git commit until you do the next release.