postcss-url icon indicating copy to clipboard operation
postcss-url copied to clipboard

copy assets to specified directory?

Open zoubin opened this issue 10 years ago • 4 comments

Right now we can specify assetPath, which determines the value of url(value) in css, and the destination of the copied asset will be calculated based on this info. That is very convenient if we want to specify a url(value) in css.

I am handling cases where the value in url(value) does not matter as long as it is right, but the destination of the copied asset does.

Here is an example.

css file /path/to/src/page/index/index.css:

.sp-icon {
  background-image: url(i/sp-icon.png);
}

the asset file is /path/to/src/page/index/i/sp-icon.png

I want to build css to /path/to/build/page/index/index.css, and the sprite to /path/to/build/sp/sp-icon.png.

So, in /path/to/build/page/index/index.css, it looks like:

.sp-icon {
  background-image: url(../../sp/sp-icon.png);
}

Any idea how to achieve this?

zoubin avatar Jun 27 '15 04:06 zoubin

If one of the provided callback for url option doesn't work for you, you can always use a custom function https://github.com/postcss/postcss-url#url-function

MoOx avatar Jun 29 '15 04:06 MoOx

The same problem.

lexich avatar Jun 29 '15 15:06 lexich

Hi guys! @zoubin i understand your problem, the next week i'm going to refactory the copy method and fix that issue.

tinchoz49 avatar Jul 05 '15 17:07 tinchoz49

FYI to people who are looking for this feature: since the above were closed and not really resolved, I ended up creating postcss-copy-assets.

alexmchardy avatar Sep 14 '15 02:09 alexmchardy