V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
coolicer
V2EX  ›  程序员

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

  •  
  •   coolicer · Dec 31, 2013 · 2459 views
    This topic created in 4508 days ago, the information mentioned may be changed or developed.
    我在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 replies    1970-01-01 08:00:00 +08:00
    fen
        1
    fen  
       Dec 31, 2013
    这是 compass 的特性,要到下个版本才有可能改善。
    这两段代码只是复制了一张没有hash名的图片并修改css代码,他生成的带hash名 png 图片不要删除,否则会继续重新生成。
    coolicer
        2
    coolicer  
    OP
       Dec 31, 2013
    @fen 好。我以为是错的,没看清楚。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2766 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 08:09 · PVG 16:09 · LAX 01:09 · JFK 04:09
    ♥ Do have faith in what you're doing.