GithubHelp home page GithubHelp logo

Comments (10)

laoshu133 avatar laoshu133 commented on June 17, 2024

应该是配置错了,请参照示例配置,https://github.com/laoshu133/grunt-css-sprite/tree/master/test
或者给出详细配置和运行日志

from grunt-css-sprite.

ereddate avatar ereddate commented on June 17, 2024

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"
}]

哪里错了?

from grunt-css-sprite.

ereddate avatar ereddate commented on June 17, 2024

css里的url(trunk/h5/imgs/aa.png)

from grunt-css-sprite.

ereddate avatar ereddate commented on June 17, 2024

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目录吗?

from grunt-css-sprite.

laoshu133 avatar laoshu133 commented on June 17, 2024

能否发一份demo到我邮箱

from grunt-css-sprite.

ereddate avatar ereddate commented on June 17, 2024

我搞定了,改了你的sprite.js和依赖项中的JS

from grunt-css-sprite.

Does666 avatar Does666 commented on June 17, 2024

如果css文件中有的引用了png图片,有的引用了svg图片,运行报错:Warning: Unsupported file type: image/svg+xml Used --force, continuing
如果css文件中只引用png图片,可以正常工作。

from grunt-css-sprite.

laoshu133 avatar laoshu133 commented on June 17, 2024

内置图片引擎不支持 svg,建议使用 png 的图

from grunt-css-sprite.

Does666 avatar Does666 commented on June 17, 2024

@laoshu133 对于即使用svg又使用png的项目,是否应用处理前先过滤掉非png格式的图片,然后再处理,这样svg即使不能生成雪碧图,也不应该报错。

from grunt-css-sprite.

laoshu133 avatar laoshu133 commented on June 17, 2024

如果有需要可以参考 可选依赖 ,使用 Graphics Magick(gm) 进行图片合并

from grunt-css-sprite.

Related Issues (20)

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.