GithubHelp home page GithubHelp logo

laoshu133 / gulp-css-spritesmith Goto Github PK

View Code? Open in Web Editor NEW
15.0 15.0 2.0 123 KB

A gulp plugin to help front engineer creating css sprite.

License: MIT License

JavaScript 27.99% CSS 63.16% HTML 8.86%

gulp-css-spritesmith's People

Contributors

laoshu133 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

zww-v5 xinfei92

gulp-css-spritesmith's Issues

按需合并图片功能

是否可以添加一个标识来按需合并图片,没有添加标识的不合并,例如以下:
background: url("css/index.png?__sprite");

最后,感谢您的插件!

gulp-src多级目录不生效

/* 自动 sprite /
gulp.task('sprite', function() {
gulp.src('build/css/
.min.css')
.pipe(cssSprite({
imagepath: './images/sprite',
imagepath_map: null,
spritedest: './images/sprite',
spritepath: '../images/',
padding: 0,
useimageset: false,
newsprite: false,
spritestamp: true,
cssstamp: true
}))
.pipe(gulp.dest('./'))
.pipe(notify({message: '雪碧图生成完成.'}));
});

配置如上,就是gulp.src()方法里面这样配置多级目录不会成功。如果把这个目录换成 gulp.src(sass/*/.scss) 就会有效果,感觉很奇怪,目录是没配错误的呀~

因为我的需求是

sass -> 编译并压缩 -> build/css/**.min.css

gulp工具生成后的结果我认为是生产环境,所以 autosprite是在sass编译完成后的css文件。请问有朋友遇到过?

图片路径不确定时能够合并图片

问题是这样的,现在我的项目想要按以下的目录结构进行重构,其中每个目录代表一个网页:

└─ src/
    ├─ index/
         ├─ img/
             └─ sprite
                 ├─ 1.png
                 └─ 2.png
         ├─ index.html
         └─ index.css
    └─ other/
         ├─ img/
             └─ sprite
                 ├─ 3.png
                 └─ 4.png
         ├─ other.html
         └─ other.css

其中我用到了 gulp-css-spritesmith 是这样的:

gulp.task('autoSprite', function() {
  return gulp.src(config.tmp + '*/*.css')
    .pipe(plugins.cssSpritesmith({
      imagepath: config.tmp + '*/img/sprite',
      spritedest: config.tmp + '*/img',
      spritepath: 'img/sprite',
      padding: 2
    }))
    .pipe(gulp.dest('./'));
});

但是其中的 imagepathspritedest 是不识别 * 的,而我的页面可能随时增加(即增加一个目录),请问要如何解决这个问题?

无法生成雪碧图?

gulp.task('moveFile',function(){

    gulp.src('./public/css/*')
        .pipe(gulp.dest('./output/css/'));

    gulp.src('./public/imgs/*/*')
        .pipe(gulp.dest('./output/imgs/'));


})

gulp.task('build',['moveFile'],function(){
    gulp.src('./output/css/*.css')
        .pipe(plugins.cssSpritesmith({
            imagepath: './output/imgs/slice/',
            spritedest: './output/imgs/sprite/',
            spritepath: '../imgs/sprite/'
        }))
        .pipe(gulp.dest('./'));
});

首次执行gulp build无法生成雪碧图

问题重现代码

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.