gpt4 book ai didi

ruby-on-rails - 在 Heroku 上的 Rails 应用程序中使用 Bootstrap 时出现 Sass::SyntaxError

转载 作者:数据小太阳 更新时间:2023-10-29 07:35:58 27 4
gpt4 key购买 nike

我按照此处的说明将文件复制到我的 Assets 目录来安装 twitter bootstrap:http://www.erikminkel.com/2013/09/01/twitter-bootstrap-3-in-a-rails-4-application/

完全按照所提供的说明执行“rake assets:precompile RAILS_ENV=development”后,我能够在我的开发 rails 服务器中使用 bootstrap 3。

但是,当我尝试执行“heroku run rake assets:precompile RAILS_ENV=production”时,出现此错误:

Sass::SyntaxError: Invalid CSS after "...ss","sources":[": expected "|", 
was ""less/theme.les..." (in /app/app/assets/stylesheets/application.css) (sass):444

我不知道这是什么意思。当我在 assets/stylesheets 文件夹中打开“application.css”时,我什至找不到第 444 行。在运行“rails g scaffold ...”命令后我确实留下了一些脚手架文件——这可能是导致这个问题?显然,当我从 heroku 页面查看已部署的 heroku 应用程序并抛出“找不到资源”错误时,它看起来像一个非 Bootstrap 应用程序。

在public/assets/application-mydigest.ccs中,我发现了下面这行导致错误的代码:

{"version":3,"file":"bootstrap-theme.css","sources":["less/theme.less","less/mixins/vendor-prefixes.less","bootstrap-theme.css","less/mixins/gradients.less","less/mixins/reset-filter.less"],"names":[],"mappings":"AAeA;;;;;;EAME,0CAAA;EC+CA,6FAAA;EACQ,qFAAA;EC5DT;AFiBC;;;;;;;;;;;;EC0CA,0DAAA;EACQ,kDAAA;EC7CT;AFqCC;;EAEE,wBAAA;EEnCH;AFwCD;EG/CI,0EAAA;EACA,qEAAA

然而,这只发生在生产环境中似乎很奇怪。此外,CSS 语法看起来不错。

最佳答案

此错误表示 Assets 编译失败,因为您在 application.css 中需要的文件中的 css 语法无效。

在 bootstrap 仓库中有一个 less 目录,你不能用 rails 预编译 less 文件。

如果你想在生产环境中使用 Rails 和 Bootstrap,我想使用 bootstrap-sass gem是更好的选择

关于ruby-on-rails - 在 Heroku 上的 Rails 应用程序中使用 Bootstrap 时出现 Sass::SyntaxError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25008564/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com