我有一個基於LESS的rails應用程序。 因爲我加了summernote html editor,所以我不得不將SASS代碼添加到我的項目中。 所以我添加這些行:Rails less/sass衝突
的Gemfile:
gem 'font-awesome-rails'
gem 'summernote-rails'
gem 'bootstrap-sass'
application.css:
*= require font-awesome
*= require summernote
在當地的一切工作正常。 當我提交申請的Heroku我得到以下錯誤:
Sass::SyntaxError: Undefined variable: "$alert-padding".
(in /tmp/build_xxx/vendor/bundle/ruby/2.1.0/gems/bootstrap-sass-3.3.1.0/assets/stylesheets/bootstrap/_alerts.scss:10)
我想我錯過了SASS變量,但不知道如何將它們添加不創建具有更少的代碼發生任何衝突。
=============編輯=================
預編譯在其發現的第一個sass變量上被中斷文件/gems/bootstrap-sass-3.3.1.0/assets/stylesheets/bootstrap/_alerts.scss
:
.alert {
padding: $alert-padding;
我想預編譯器沒有任何SASS變量聲明,並不能預編譯它找到任何首位。
=============編輯=================
我加入到我的application.scss
的@import
我明白我需要有,現在它看起來像這樣:
@import "bootstrap-sprockets";
@import "bootstrap/variables";
@import "bootstrap/mixins";
@import "bootstrap";
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* 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 custom_bootstrap/custom_bootstrap
*= require custom
*= require social-share-button
*= require bootstrap-datetimepicker
*= require dataTables/jquery.dataTables
*= require dataTables/src/demo_table_jui
*= require pricing
*= require jquery.fileupload-ui
*= require font-awesome
*= require social-buttons-3.css
*= require summernote
*/
我肯定有包括_variables.scss
(我給它改名,以確保),我看到$alert-padding
聲明:
$alert-padding: 15px !default;
$alert-border-radius: $border-radius-base !default;
$alert-link-font-weight: bold !default;
不過,我得到這個錯誤!
PD - 我用下面的命令,以本地檢查預編譯:
RAILS_ENV=development bundle exec rake assets:precompile
我已經有'gem'sass-rails''在我的Gemfile中。我將'application.css'重命名爲'scss'擴展,但我不知道如何將其內容轉換爲sass樣式(即'@ import'而不是'* = require')。 我意識到我的問題是沒有包含sass變量,實際上預編譯在第一個變量找到時被破壞...但不知道如何包含他們的聲明! – guyaloni