Step 1: The development configuration config.rb
should look like this:
# Basic configuration.
http_path = "/"
css_dir = "css"
sass_dir = "sass"
images_dir = "images"
javascripts_dir = "js"
# You can select your preferred output style here (can be overridden via the command line).
# Options: ":expanded", ":nested", ":compact", ":compressed"
output_style = :expanded
# Enable debugging comments that display the original location of your selectors.
line_comments = true
# Re-compile the sass files using the minified configuration.
on_stylesheet_saved do
`compass compile -c config_minified.rb --force`
end
Step 2: You must add another configuration file config_minified.rb
and it should look like this:
# Basic configuration.
http_path = "/"
css_dir = "css/minified"
sass_dir = "sass"
images_dir = "images"
javascripts_dir = "js"
# Compressed the output for production.
output_style = :compressed
# Disable debugging comments for production.
line_comments = false
Step 3: Compile as usual and you are ready to go:
compass watch
The /css/minified/style.css
will automatically generated.
After you follow these steps the project should looks like this:
/css
/css/style.css
/css/minified/style.css
/images
/sass
/sass/style.scss
config.rb
config_minified.rb
EDIT
If you don't want to mess with relative path per project you can alter the config_minified.rb
in order to use a css folder relative to the root folder.
# do not use the css_dir = "css/minified" because it will break the images.
css_dir = "css-minified"