• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

weixin/gulp-tmtsprite: Gulp CSS 雪碧图合并

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

weixin/gulp-tmtsprite

开源软件地址(OpenSource Url):

https://github.com/weixin/gulp-tmtsprite

开源编程语言(OpenSource Language):

JavaScript 89.1%

开源软件介绍(OpenSource Introduction):

gulp-tmtsprite NPM version devDependency Status

Automatically generate sprites image and CSS.
(with retina @2x, @3x supported)

NPM Home Page: https://www.npmjs.com/package/gulp-tmtsprite

Install

Install with NPM:

npm install gulp-tmtsprite --save
npm install gulp-if --save

Usage

gulpfile.js

var gulpif = require('gulp-if');
var tmtsprite = require('gulp-tmtsprite');

gulp.src('./src/css/style-*.css')
    .pipe(tmtsprite())
    .pipe(gulpif('*.png', gulp.dest('./dist/sprite/'), gulp.dest('./dist/css/')));
        	

Options Custom your slice image path

var gulpif = require('gulp-if');
var tmtsprite = require('gulp-tmtsprite');

gulp.src('./src/css/style-*.css')
    .pipe(tmtsprite({slicePath: '../slice'}))
    .pipe(gulpif('*.png', gulp.dest('./dist/sprite/'), gulp.dest('./dist/css/')));

Result

CSS In -> style-index.less

.icon-test {
	width: 32px;
	height: 32px;
	background-image: url(../slice/test.png);
}

Tips: try gulp-LazyImageCSS if you are too lazy to type image width / height and more.

CSS Out -> style-index.css

.icon-test {
	background-image: url(../sprite/style-index.png);
}

// Retina 2x supported
@media only screen and (-webkit-min-device-pixel-ratio: 2),
only screen and (min--moz-device-pixel-ratio: 2),
only screen and (-webkit-min-device-pixel-ratio: 2.5),
only screen and (min-resolution: 240dpi) {
.icon-test { 
	background-image:url("../sprite/[email protected]");
	background-position: -36px -66px;
	background-size: 32px;
}
}

Tips: Retina 3x is ready based on image name, like [email protected] with @3x string inside.


Image In -> ./slice/*.png

image-in

Image Out -> ./sprite/style-index.png

image-out

Tips: 3x sprite is an option when needed.

Know Issues

Release History

  • 0.0.21 Fix replacing of slice refference in different quote style
  • 0.0.14 Retina @3x supported
  • 0.0.12 @2x image background-postion fixed
  • 0.0.10 Duplicate slice using supported
  • 0.0.1 First Release

Team & License




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
gucong3000/build-script: Gulp发布时间:2022-06-22
下一篇:
luwen-huang/angular-gulp-webpack-starter: template starter kit demonstrating ang ...发布时间:2022-06-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap