V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
coolicer
V2EX  ›  程序员

使用compass sprite的时候怎么让它不再次生成文件名

  •  
  •   coolicer · 2013-12-31 10:14:40 +08:00 · 2072 次点击
    这是一个创建于 3829 天前的主题,其中的信息可能已经有所发展或是发生改变。
    我在config.rb贴上这个也不行。

    # Make a copy of sprites with a name that has no uniqueness of the hash.
    on_sprite_saved do |filename|
    if File.exists?(filename)
    FileUtils.cp filename, filename.gsub(%r{-s[a-z0-9]{10}\.png$}, '.png')
    end
    end

    # Replace in stylesheets generated references to sprites
    # by their counterparts without the hash uniqueness.
    on_stylesheet_saved do |filename|
    if File.exists?(filename)
    css = File.read filename
    File.open(filename, 'w+') do |f|
    f << css.gsub(%r{-s[a-z0-9]{10}\.png}, '.png')
    end
    end
    end
    2 条回复    1970-01-01 08:00:00 +08:00
    fen
        1
    fen  
       2013-12-31 10:32:39 +08:00
    这是 compass 的特性,要到下个版本才有可能改善。
    这两段代码只是复制了一张没有hash名的图片并修改css代码,他生成的带hash名 png 图片不要删除,否则会继续重新生成。
    coolicer
        2
    coolicer  
    OP
       2013-12-31 13:47:12 +08:00
    @fen 好。我以为是错的,没看清楚。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   4752 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 01:12 · PVG 09:12 · LAX 18:12 · JFK 21:12
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.