2createStudio / postcss-sprites

Generate sprites from stylesheets.
MIT License
413 stars 50 forks source link

@2x group repeated many times when used with postcss-cli #63

Closed zyy7259 closed 8 years ago

zyy7259 commented 8 years ago

the @2x group will be generated many times when used with postcss-cli, so the generated file path is something like sprite.@2x.@2x.@2x.......@2x.@2x.@2x.group.png.

Haven't look into the code carefully.

Currently, I just provide a onSaveSpritesheet hook to filter the unnecessary @2x group.

      onSaveSpritesheet (opts, groups = []) {
        groups = groups.filter((item, index) => {
          return groups.indexOf(item) === index
        })
        // the following line of code is copied from method `makeSpritesheetPath` of the source code
        // which is the default function to generate file path if no onSaveSpritesheet is provided.
        return path.join(opts.spritePath, ['sprite', ...groups, 'png'].join('.'))
      },