Rails 如何让 assets:precompile 不编译部分文件

bpw11320 · November 16, 2013 · Last by lululau replied at November 17, 2013 · 2109 hits

RT,在 js lib 或者 css lib 中有些图片不想通过 rails assets:precompile 进行编译,增加指纹后缀,该如何配置呢?

Unknow user #1 November 16, 2013

那你如何可以访问得到?

不 precompile 的话怎么做指纹后缀?

或者写一个脚本,每次改动之后生成新的文件放在 public 里面。

试试这个 gem:turbo-sprockets-rails3,可以只编译有改动的文件

写个脚本把未加指纹的文件都拷贝到 asset 中去就好了

手动打包

config.assets.precompile = [...] 把你想要编译的文件(可以用 Regexp/String/Proc 指定)加入到这个数组里即可,Rails 默认是:

[ Proc.new { |path, fn| fn =~ /app\/assets/ && !%w(.js .css).include?(File.extname(path)) },
/application.(css|js)$/ ]
You need to Sign in before reply, if you don't have an account, please Sign up first.