Skip to content

copy assets to specified directory? #34

Open

Description

@zoubin

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?

Activity

  1. MoOx commented on Jun 29, 2015

    @MoOx
    Collaborator

    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

  2. lexich commented on Jun 29, 2015

    @lexich
    Contributor

    The same problem.

  3. tinchoz49 commented on Jul 5, 2015

    @tinchoz49
    Contributor

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

  4. added a commit that references this issue on Jul 7, 2015
    f4a6f5b
  5. alexmchardy commented on Sep 14, 2015

    @alexmchardy

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions