简体   繁体   中英

How to get rails asset pipeline compile coffee script and scss file?

This may have been asked before. And I have searched through stack overflow with some solutions . I tried to implement those with little :). I am stuck. Please help. I am new to rails

I have several scss fils in the assts folder as in below

assets
    javascript
       application.js
       create.js.coffee
       help.js.coffee
    images

    stylesheets
       application.css
       create.css.scss
       forms.css.scss
       help.css.scss

What I need is to compile these files in the ruby asset pipeline such that it compiles and then combines so that styles && scripts show up which is not showing up on my website.

in the application.js I have

// This is a manifest file that'll be compiled into including all the files listed below.
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
// be included in the compiled file accessible from http://example.com/assets/application.js
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
//= require jquery
//= require jquery_ujs
//= require_tree .

In the application.css, I have

/*
 * This is a manifest file that'll automatically include all the stylesheets available in this directory
 * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
 * the top of the compiled file, but it's generally better to create a new file per style scope.
 *= require_self
 *= require_tree .
 *= require 'site'
*/

Also, in production.db I have

  # Compress JavaScripts and CSS
  config.assets.compress = true

  # Don't fallback to assets pipeline if a precompiled asset is missed
  config.assets.compile = false

  # Generate digests for assets URLs
  config.assets.digest = true

Please help to get this compiled . Any ideas?

You must set RAILS_ENV value before assets precompile, because by default RAILS_ENV equal 'development', but you need set 'production'. Try this:

RAILS_ENV=production bundle exec rake assets:precompile

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM