I have a problem with asset precompile. When I try to precompile assets for production mode using:
RAILS_ENV=production bundle exec rake assets:precompile
this error appears:
DEPRECATION WARNING: The configuration option `config.serve_static_assets` has been renamed to `config.serve_static_files` to clarify its role (it merely enables serving everything in the `public` folder and is unrelated to the asset pipeline). The `serve_static_assets` alias will be removed in Rails 5.0. Please migrate your configuration files accordingly. (called from block in tsort_each at /usr/local/lib/ruby/2.2.0/tsort.rb:226)
I, [2016-06-15T18:06:55.828561 #19627] INFO -- : Writing /home/rails/Desktop/hammasir/public/assets/bootstrap.min-f3ab05f17df205c2d2a559852b8609eaa090ea127ff142bfb6ebf090ee187fd4.css
I, [2016-06-15T18:06:55.913275 #19627] INFO -- : Writing /home/rails/Desktop/hammasir/public/assets/bootstrap.min-f3ab05f17df205c2d2a559852b8609eaa090ea127ff142bfb6ebf090ee187fd4.css.gz
rake aborted!
Sass::SyntaxError: Invalid CSS after "}": expected selector or at-rule, was "}"
(sass):86
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
zlib(finalizer): Zlib::GzipWriter object must be closed explicitly.
zlib(finalizer): the stream was freed prematurely.
Some other css files are also have the same problem. It seems that the mentioned files are ok, there's not any missed } or ; . Also, all of these files are well-known css files like bootstrap! I checked these files with different css debuggers and the results were different. One time without any error just some warnings, and one time with similar error in multiple lines:
Sorry, the at-rule @-webkit-keyframes is not implemented.
Please let me know if you have a solution for this problem.
In addition, I deployed my app on Heroku and tried to add these files after successful deployment. Unfortunately, the files caused my app to be crashed. So, I think I should find a way to precompile them successfully in the production mode.
As I found the answer, I'm writing it here, wishing it to be useful for others.
To solve the DEPRECATION WARNING, check this link:
Asset pipeline DEPRECATION WARNING tsort.rb:226
And about the error, you should find which file causes the error exactly. The generated error and mentioned files in it are misleading.
You can work with your assets.rb
file to find which file (files) contains syntax error. Comment or remove all of the referred files in assets.rb
except one and redo asset precompile command in your production mode:
RAILS_ENV=production bundle exec rake assets:precompile
and repeat it for all css files to understand which one contains the error. This time the output of this command will be helpful and refer exactly to the problem. Then, it would be easy to find the error and fix it.