Mathieu
Mathieu

Reputation: 4787

Do sass/scss files compile to render the final css file on production on each user page load?

I am creating a ruby on Rails app with the usual tools (rails pipeline and rails sass (gem 'sass-rails') and deploy to Heroku.

I am a newbie and what I fail to understand with scss/sass is:

I can cope with the larger compile time while in dev mode not in production (I'd rather avoid it). At least I need to know if even in production, the css given as example below, will need to go and fetch the scss files

Exemple:

.brand {
    @include vertical-align(absolute);
    color: $brandColor;
    right: 1em;
}

Upvotes: 2

Views: 633

Answers (2)

James Keane
James Keane

Reputation: 43

Rails will use an assets pipeline in your application. Using the files application.css and application.js in your app/assets folder, it will go through the files 'required', and compile them to a single file.

It will process them from Coffee -> JS and SCSS/LESS -> CSS if these Gems are part of your hierarchy.

You can use the following to check the precompilation:

RAILS_ENV=production bin/rake assets:precompile

Upvotes: 1

MurifoX
MurifoX

Reputation: 15089

In production the assets are precompiled, generating 2 minified files, one for the javascript and one for the css.
In development they are precompiled on each request, but you can simulate the minified one version by changing some options in your development.rb file.

Upvotes: 1

Related Questions