首页 > 解决方案 > 尝试部署到heroku时预编译资产失败

问题描述

我正在尝试使用终端命令将我的应用程序部署到 heroku git push heroku master,但它在资产预编译期间失败,我无法理解错误消息。

我得到错误:

    remote:        I, [2019-09-07T14:40:57.856531 #1633]  INFO -- : Writing /tmp/build_1e97b201914388013420d438aaf972eb/public/assets/application-6e5c569b523cb8b97f659b2b254c3a9c22a7cbd1d9c4f17afaf18019084c6544.js.gz
    remote:        rake aborted!
    remote:        SassC::SyntaxError: Error: Invalid CSS after "...e* bootstrap.*/": expected 1 selector or at-rule, was "*/"
    remote:                on line 14:76 of app/assets/stylesheets/application.scss
    remote:        >> t be set or imported *before* bootstrap.*/
    remote:        
    remote:           ------------------------------------------^

在 application.sccs 中,曾经有一行:

    /* Custom bootstrap variables must be set or imported *before* bootstrap. */
    @import "bootstrap";
    @import "bootstrap/scss/bootstrap"

但是我已经删除了第一行,现在从第 14 行开始,我只有:

    @import "bootstrap";
    @import "bootstrap/scss/bootstrap"

但问题仍然存在。

标签: ruby-on-railsherokuruby-on-rails-5

解决方案


简单的错误可能是最难追踪的......

你只是少了一个分号......

@import "bootstrap";
@import "bootstrap/scss/bootstrap";  # <= that one

另请注意,您删除的行是 CSS 注释(介于 之间/* */


推荐阅读