Open ereddate opened 8 years ago
应该是配置错了,请参照示例配置,https://github.com/laoshu133/grunt-css-sprite/tree/master/test 或者给出详细配置和运行日志
options: {
// 映射CSS中背景路径,支持函数和数组,默认为 null
imagepath_map: null,
// 各图片间间距,如果设置为奇数,会强制+1以保证生成的2x图片为偶数宽高,默认 0
padding: 2,
// 是否使用 image-set 作为2x图片实现,默认不使用
useimageset: false,
// 是否以时间戳为文件名生成新的雪碧图文件,如果启用请注意清理之前生成的文件,默认不生成新文件
newsprite: false,
// 给雪碧图追加时间戳,默认不追加
spritestamp: false,
// 在CSS文件末尾追加时间戳,默认不追加
cssstamp: false,
// 默认使用二叉树最优排列算法
algorithm: 'binary-tree',
// 默认使用pixelsmith
图像处理引擎
engine: 'pixelsmith',
// sprite背景图源文件夹,只有匹配此路径才会处理,默认 images/slice/
imagepath: 'trunk/h5/imgs/',
// 雪碧图输出目录,注意,会覆盖之前文件!默认 images/
spritedest: 'dist/h5/imgs/',
// 替换后的背景路径,默认 ../images/
spritepath: '../../imgs/'
},
files: [{
// 启用动态扩展
expand: true,
// css文件源的文件夹
cwd: 'temp/h5/css/',
// 导出css和sprite的路径地址
dest: 'dist/h5/css/',
// 匹配规则
src: '*.css',
// 导出的css名
ext: ".min.css"
}]
哪里错了?
css里的url(trunk/h5/imgs/aa.png)
imageSetSprite: { options: { useimageset: true, imagepath_map: ['/w/grunt-css-sprite/test/', '../'], / imagepath_map: function(uri) { return String(uri).replace('/w/grunt-css-sprite/test/', '../'); }, / spritedest: 'test/publish/images/imageset/' },
你那里是这样写的,imagepath_map不是为空吗?输入目录必须是有publish目录吗?
能否发一份demo到我邮箱
我搞定了,改了你的sprite.js和依赖项中的JS
如果css文件中有的引用了png图片,有的引用了svg图片,运行报错:Warning: Unsupported file type: image/svg+xml Used --force, continuing 如果css文件中只引用png图片,可以正常工作。
内置图片引擎不支持 svg,建议使用 png 的图
@laoshu133 对于即使用svg又使用png的项目,是否应用处理前先过滤掉非png格式的图片,然后再处理,这样svg即使不能生成雪碧图,也不应该报错。
css: #section0{ background-image: url(trunk/h5/imgs/bg1.png); gruntfile: imagepath: 'trunk/h5/imgs/'
这样也输不出来图片,是怎么回事?