assets:precompile
タスクの奇妙な動作の前、または少なくとも私が完全に理解していないものの前に自分自身が見つかりました。Railsアセット:奇妙な動作のプリコンパイル
私はWebアプリケーション用にRails 3.1.3、Sprockets 2.0.3、Less 2.0.11を使用していますが、レイアウト用にBootstrapを使用していますので、less-rails 2.1.8以下も使用しています。 -rails-bootstrap 2.0.8。 hereと同じようにスタイルをカスタマイズしました。
私の資産の構成は次のとおりです。application.css.scssで
stylesheets
|--application.css.scss
|--custom-style/
|--variables.less
|--mixins.less
|--buttons.less
|--custom-style.css.less
私は
//=require custom-style
そして、私はbuttons.less
で最後に
@import "twitter/bootstrap/reset";
//@import "twitter/bootstrap/variables"; // Modify this for custom colors, font-sizes, etc
@import "custom-style/variables";
//@import "twitter/bootstrap/mixins";
@import "custom-style/mixins";
// And all the other standar twitter/bootstrap imports...
// Other custom-style files to import
@import "custom-style/buttons"
//...
// And other rules here
//...
を行うカスタムスタイルで操作を行います私は、variables.less
とmixins.less
Bで定義されているいくつかの変数とミックスインを使用していますootstrapファイル、@white
および.buttonBackground
を指定してください。
私は上記の構成でbundle exec rake assets:precompile
を起動すると、タスクが失敗し、私はこのエラーを取得する:
$ bundle exec rake assets:precompile
/usr/local/rvm/rubies/ruby-1.9.3-p0/bin/ruby /usr/local/rvm/gems/ruby-1.9.3-p0/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
rake aborted!
.buttonBackground is undefined
しかし、私がしなければ、これは
buttons.less --> buttons.css.less
@import "buttons" --> @import "buttons.css.less"
すべてが正常に動作変化することです!
ネストされたインポートで作業する場合、変数と関数の範囲が狭いのですか?あるいは、以下のパーサ、すなわちSprocketsがインポートツリーを処理する順序と関係があるものはありますか?
私は何かを見逃しているか間違った方法で何かをしていますか?
感謝:)
注:は私も元の変数とミックスインファイルでエラーが出るので、それはそれらに行わオーバーライドと接続されていません。
"私は自分自身を資産の奇妙な振る舞いの前に見つけました:プリコンパイルタスク" - 私たちはすべてありません:) また、application.css.scssとあなたの.lessファイルを混在させると、問題。// LESS/SASSのどちらかを試してみると、Sassはあなたの@import指令を認識していないかもしれません。それは必要ではないので、application.css.scss-> application.cssを変更し、Gemfileからsass-railsを削除し、役立つかどうか確認してください。幸いです:) – sbeam