dav*_*aro 8 css ruby-on-rails-3 asset-pipeline twitter-bootstrap
我创建了一个全新的Rails 3.1应用程序.我在app/assets/stylesheets/bootstrap.min.css中添加了twitter bootstrap CSS文件.这是相关的代码
app/assets/stylesheets/application.css(包括树,因此包含bootstrap)
/*
* This is a manifest file that'll automatically include all the stylesheets available in this directory
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
* the top of the compiled file, but it's generally better to create a new file per style scope.
*= require_self
*= require_tree .
*/
Run Code Online (Sandbox Code Playgroud)
Gemfile(包括用于编译/压缩的execjs和therubyracer)
group :development, :qa do
gem 'execjs'
gem 'therubyracer'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.1.0'
gem 'coffee-rails', '~> 3.1.0'
gem 'uglifier', '>= 1.0.3'
end
Run Code Online (Sandbox Code Playgroud)
然后我运行rake任务来预编译资产
rake assets:precompile
Run Code Online (Sandbox Code Playgroud)
这失败,出现以下错误
Invalid CSS after ".inputs-list li+": expected number or function, was "li"
Run Code Online (Sandbox Code Playgroud)
CSS在引导程序文件中(".inputs-list li + li"是选择器).
但是,如果我跑
rake assets:precompile RAILS_ENV=development
Run Code Online (Sandbox Code Playgroud)
现在它工作正常.事实证明,如果我将config/environments/production.rb更改为不压缩文件:
config.assets.compress = false
Run Code Online (Sandbox Code Playgroud)
那么原始命令也可以工作(没有指定开发环境).
那么,我该如何追踪错误?我现在可以忍受只是关闭压缩,但显然有些不对劲.是Rails吗?链轮?红宝石赛车?Uglifier?
我建议使用其中一个将bootstrap转换为sass的库,并将其合并到资产管道中.通过这种方式,您将获得JS,您可以更改bootstrap在preboot.scss文件中使用的变量,并且您可以选择要合并的功能.您还可以使用bundler进行升级.
我使用bootstrap-sass并且效果很好:https://github.com/thomas-mcdonald/bootstrap-sass
| 归档时间: |
|
| 查看次数: |
2816 次 |
| 最近记录: |