Rails: Use livereload with Asset Pipeline

前端 未结 3 1792
北海茫月
北海茫月 2020-12-15 08:23

Quick question for rails pros out there...

When working with Rails 3.0.x apps I was a heavy user of Guard and LiveReload. However, it seems that when using the asset

3条回答
  •  一整个雨季
    2020-12-15 08:42

    After following some issue threads on Github I found the following fixed my problem:

    1) Make sure all scss files are named following the new asset convention, like so: filename.css.scss

    I was using scss before Rails 3.1 and had just named all my sass files filename.scss.

    2) Use the following for livereload in your guardfile:

    guard 'livereload' do
      watch(%r{app/helpers/.+\.rb})
      watch(%r{app/views/.+\.(erb|haml)})
      watch(%r{(public/).+\.(css|js|html)})
      watch(%r{app/assets/stylesheets/(.+\.css).*$})    { |m| "assets/#{m[1]}" }
      watch(%r{app/assets/javascripts/(.+\.js).*$}) { |m| "assets/#{m[1]}" }
      watch(%r{lib/assets/stylesheets/(.+\.css).*$})    { |m| "assets/#{m[1]}" }
      watch(%r{lib/assets/javascripts/(.+\.js).*$}) { |m| "assets/#{m[1]}" }
      watch(%r{vendor/assets/stylesheets/(.+\.css).*$}) { |m| "assets/#{m[1]}" }
      watch(%r{vendor/assets/javascripts/(.+\.js).*$})  { |m| "assets/#{m[1]}" }
      watch(%r{config/locales/.+\.yml})
    end
    

提交回复
热议问题