Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can SASS/Compass compile foo.scss to foo.min.css and foo.dbg.css?

I want to compile a set of .scss files to different filenames.

In development, I want to compile eg. foo.scss to foo.dbg.css (unminified and with comments). In production, I want to have eg. foo.min.css (minified).

Is there a way to tell SASS/Compass what to use as the target extension? A command-line switch? A config.rb option?

Writing a script that first compiles and then renames files seems like a bad option, because then I can't use compass watch efficiently.

(Well, I could compile to two different output directories and then write a script that copies the files from there. That feels a bit clumsy.)

UPDATE: I worked around the problem by writing a simplified version of the watch code. When something changes, it triggers a recompile to two different output directories, then renames and moves the files to place.

like image 202
tuomassalo Avatar asked Sep 13 '12 10:09

tuomassalo


People also ask

What is Compass CSS?

Compass is an open-source CSS Authoring Framework. Experience cleaner markup without presentational classes. It's chock full of the web's best reusable patterns. It makes creating sprites a breeze. Compass mixins make CSS3 easy. Create beautiful typographic rhythms.

How do I import a compass into sass?

Open a . sass or . scss file, click the red bulb next to the @import 'compass' statement or press Alt+Enter , and then choose Configure Compass from the suggestion list.


2 Answers

I couldn't get Alireza Fattahi's answer to work because it threw errors so I found another example which works for me

http://h3r2on.com/2013/05/17/rename-css-on-compile.html

require "fileutils"

on_stylesheet_saved do |file|
  if File.exists?(file)
    filename = File.basename(file, File.extname(file))
    File.rename(file, css_dir + "/" + filename + ".min" + File.extname(file))
  end
end
like image 159
AdRock Avatar answered Sep 28 '22 16:09

AdRock


No it can't. I asked the same question in the mailing lists about RTL stylesheets. However, you can run compass compile using different 'config.rb' files. Try compass compile -c debug.rb.

UPDATE: Compass still can't, but Gulp can watch and generate several target css files using Sass and Compass. See https://github.com/Snugug/gulp-css-target/

like image 44
Capi Etheriel Avatar answered Sep 28 '22 17:09

Capi Etheriel