rake assets:precompile throws Sass::SyntaxError: Invalid CSS after “*/”

后端 未结 6 1300
小鲜肉
小鲜肉 2021-01-02 04:21

I hope this isn\'t a duplicate problem; I\'ve tried other solutions on SO with no effect

When pushing my app to Heroku, the push has failed because applicat

相关标签:
6条回答
  • 2021-01-02 04:57

    SOLUTION

    The file that was breaking things was the font awesome CSS. Removing that from application.css's "require" lines allowed the precompilation to work.

    The way to do this was to first delete all of the precompilation require fields, showing that it would compile, and then to slowly add the require fields back to see where it broke.

    (Thanks for all those who helped figure this out.)

    0 讨论(0)
  • 2021-01-02 04:57

    I ran into a similar issue as well and stumbled upon this thread. Turned out for me, I left a } off of the end of one of my CSS statements. Added it in and I was back up within minutes.

    0 讨论(0)
  • 2021-01-02 04:59

    I'm a newbie to rails and was having a similar issue when pushing to heroku. A friend looked at my application.css file and noticed that I had

    *= require bootstrap

    and

    *= require bootstrap-datetimepicker

    below the */

    Removing them allowed me to push successfully.

    0 讨论(0)
  • 2021-01-02 05:00

    For me, I forgot to add # in front of the class sign-in.

    It should be

    #sign-in 
      (your code)
    
    0 讨论(0)
  • 2021-01-02 05:03

    Even though you found your way to fix it, I'm gonna share my solution too, because I was facing the same issue and it was kinda hard to debug it.

    You're probably using rails 3.2, sass-rails 3.2 and font-awesome-sass 4.1.

    It turns out that the rails 3.2 uses sass-rails 3.2.6, which depends on sass >= 3.1. However, It looks like sass 3.1 is not compatible with font-awesome 4.1, so I explicitely set the sass gem to use version 3.2 on my Gemfile.

    gem 'sass-rails', '~> 3.2.6'
    gem 'sass', '~> 3.2.0'
    

    Hope this helps someone! ;)

    0 讨论(0)
  • 2021-01-02 05:03

    Another way to solve this is to explicitly tell the asset-pipeline to use the css version of the asset over the scss one. For example, if you're importing a .scss file in your application.scss like this:

    @import "angular-material";      # this will use scss version of the asset
    

    You can alternatively tell it to use the css version like so:

    @import "angular-material.css";  # this will use the css version
    

    Most vendors provide scss and css versions, so it is useful to rely on css versions of assets especially when using vendor assets. Remember everything will be precompiled and uglified in the end, so wither you use scss or css they all end up the same.

    0 讨论(0)
提交回复
热议问题