请帮我理解究竟heroku run rake assets:precompile是什么.自从我开始在rails上使用ruby之后,我总是在推送到github和heroku之前运行这三个命令:
bundle exec rake assets:precompile
RAILS_ENV=production bundle exec rake assets:precompile
在我推到heroku后,我会跑:
heroku run rake assets:precompile
但是,当我在上次推送到heroku后尝试运行它时,我在不同的文件上遇到了一堆相同的错误.例如:
Warning. Error encountered while saving cache ... can't dump anonymous class ...
为了看看我能解决这个问题,我跑了
heroku run rake assets:clean再heroku run rake assets:precompile一次.问题是一切都运转正常,但我觉得如果有这些警告/错误.请帮我理解.谢谢!
我正在尝试将我的rails应用程序部署到生产中,并且我正在尝试预编译所有资产:
我的assets.rb文件:
Rails.application.config.assets.precompile += %w( *.css.sass )
Rails.application.config.assets.precompile += %w( *.css.scss )
Rails.application.config.assets.precompile += %w( *.css )
Rails.application.config.assets.precompile += %w( *.js )
Rails.application.config.assets.precompile += %w( *.js.coffee )
Rails.application.config.assets.precompile += %w( *.js.coffee.erb )
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试使用capistrano进行部署时,出现以下错误:
DEBUG[c79c6191] rake aborted!
DEBUG[c79c6191] Sass::SyntaxError: Undefined variable: "$alert-padding".
Run Code Online (Sandbox Code Playgroud)
在我之前的assets.rb文件中,我已经逐个文件地添加了每个资产,并且部署正在运行,但是,我正在布局文件中导入一些资产:
<%= javascript_include_tag 'application', 'jquery-ui-1.9.2', 'js-example', 'js-example2', 'data-turbolinks-track' => true %>
Run Code Online (Sandbox Code Playgroud)
但我也使用链轮导入一些:
//= require jquery
//= require bootstrap-sprockets
//= require angular
//= require jquery_ujs
//= require turbolinks
//= require_tree .
Run Code Online (Sandbox Code Playgroud)
这个方法在我开发应用程序时运行良好,但是当我将应用程序部署到生产环境时,似乎我使用链轮导入的东西没有被导入(即Angular)
提前致谢.
编辑:根据要求,我的application.css.scss文件:
/*
*
*= require_tree .
*= …Run Code Online (Sandbox Code Playgroud) 我bootstrap-sass在我的Rails 4应用程序中使用了gem,我使用了Glpyphicons字体,它包含了我的应用程序中的图标引导程序.在开发过程中,这些图标显示得很好.但是,在任何非开发环境中,每次对Glyphicon字体文件的引用都会出现404错误.
我已经确定这是由于资产管道打破了Bootstrap样式表中的引用所做的指纹识别.
Bootstrap引用这些字体:
@font-face {
font-family: 'Glyphicons Halflings';
src: url("bootstrap/glyphicons-halflings-regular.eot");
src: url("bootstrap/glyphicons-halflings-regular.eot?#iefix") format("embedded-opentype"), url("bootstrap/glyphicons-halflings-regular.woff") format("woff"), url("bootstrap/glyphicons-halflings-regular.ttf") format("truetype"), url("bootstrap/glyphicons-halflings-regular.svg#glyphicons_halflingsregular") format("svg");
}
Run Code Online (Sandbox Code Playgroud)
但是,快速ls的bootstrap文件夹显示名称不同.
glyphicons-halflings-regular-293ade90ddeb5ceccd08b9b32ae97010.eot
glyphicons-halflings-regular-533d84fb5d3948367e1b51dde3a08b39.svg
glyphicons-halflings-regular-d381f367f3f48c9f7f775a043238f0f8.ttf
glyphicons-halflings-regular-e5b007f195d752fa4823febe5e66ef4e.woff
Run Code Online (Sandbox Code Playgroud)
如您所见,每个文件都附加了指纹.
删除这些指纹可以解决问题.但是,手动执行此操作并不适合部署.有没有人有这方面的解决方案?bootstrap-sass如果可以帮助我,我想避免编辑gem代码.
谢谢!
asset-pipeline bootstrap-sass ruby-on-rails-4 asset-finger-printing precompile-assets