bootstrap-sass: Undefined variable: “$baseLineHeight”

随声附和 提交于 2019-11-28 20:33:49

You've edited your production.rb file so that Rails will attempt to precompile all CSS/JS files (line 48).

By default Rails will only precompile application.css(.scss). By adding the wildcard selector to config.assets.precompile you are asking Rails to precompile every css asset in your application, including Sass partials. Naturally, this is probably not the behaviour you wish for.

# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
config.assets.precompile += %w( *.css *.js )

Rails will therefore iterate over each css asset, compiling them. It so happens that _accordion.css.scss is the first Bootstrap asset it comes across, and Rails will attempt to compile that first. _accordion isn't independent, and requires some files to be loaded before it, hence the error. It should never be compiled as a separate file anyway.

You need to change your config.assets.precompile to add only the additional files that you need aside from application.css/application.js.

Benjamin Udink ten Cate

You need to make sure the import of all your css is done in the proper order. For variables to work it needs to be one of the first few css files to be loaded.

This post/answer should help Proper SCSS Asset Structure in Rails

Initially I had the similar problem Sass::SyntaxError: Undefined variable: "$alert-padding". problem with this line in the assets.rb file:

Rails.application.config.assets.precompile += [/.*\.css/] 

Don't know why but for me it helped to change it to this line

Rails.application.config.assets.precompile += [/^[-_a-zA-Z0-9]*\..*/]

After it the problem was solved and everything worked in production.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!