我在执行资产时遇到以下错误:使用ruby 2.4.3
和rails 5.1.4
进行预编译
Sass :: SyntaxError:" *"之后的无效CSS:期望的选择器,是" = 需要靴子......"
RAILS_ENV=production rails assets:precompile
application.scss文件内容如下。
*= require bootstrap-datepicker
*= require datetimepicker
*= require chosen
*= require reports_kit/application
*= require_tree
*= require_self
*/
@import "patternfly-sprockets";
@import "patternfly";
@import 'timepiece';
$ RAILS_ENV=production rails assets:precompile --trace
** Invoke assets:precompile (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Invoke yarn:install (first_time)
** Execute yarn:install
** Execute assets:precompile
rails aborted!
Sass::SyntaxError: Invalid CSS after "*": expected selector, was "= require boots..."
(sass):3333
/home/fabritronix/.rvm/gems/ruby-2.4.3/gems/sass-3.4.25/lib/sass/scss/parser.rb:1207:in `expected'
/home/fabritronix/.rvm/gems/ruby-2.4.3/gems/sass-3.4.25/lib/sass/scss/parser.rb:1137:in `expected'
/home/fabritronix/.rvm/gems/ruby-2.4.3/gems/sass-3.4.25/lib/sass/scss/static_parser.rb:21:in `parse_selector'
/home/fabritronix/.rvm/gems/ruby-2.4.3/gems/sass-3.4.25/lib/sass/tree/visitors/perform.rb:428:in `visit_rule'
/home/fabritronix/.rvm/gems/ruby-2.4.3/gems/sass-3.4.25/lib/sass/tree/visitors/base.rb:36:in `visit'
/home/fabritronix/.rvm/gems/ruby-2.4.3/gems/sass-3.4.25/lib/sass/tree/visitors/perform.rb:162:in `block in visit'
/home/fabritronix/.rvm/gems/ruby-2.4.3/gems/sass-3.4.25/lib/sass/stack.rb:79:in `block in with_base'
/home/fabritronix/.rvm/gems/ruby-2.4.3/gems/sass-3.4.25/lib/sass/stack.rb:115:in `with_frame'
/home/fabritronix/.rvm/gems/ruby-2.4.3/gems/sass-3.4.25/lib/sass/stack.rb:79:in `with_base'
答案 0 :(得分:1)
尝试以下方法以获得最佳实践
从application.scss
*= require bootstrap-datepicker
*= require datetimepicker
*= require chosen
*= require reports_kit/application
*= require_tree
*= require_self
*/
如果你需要这些库,那么在stylesheets
文件夹中创建一个文件,如custom.css
,并将这些CSS库放在这里,并确保你的拼写错误就像*= require_tree .
或者您可以将application.scss
重写为application.css.scss
来纠正错误,例如*= require_tree .
希望能提供帮助