5

I have done compass create . and compass init rails whilst in my project directory. A few questions:

  • I have placed my .sass files in public/stylesheets. Is this the right place to put them?
  • When I run compass watch, it does not automatically compile these .sass files. I have to manually specify the files: compass watch public/stylesheets/myfile.sass etc. How do I get this working automatically?
  • The files ie.css, print.css and screen.css have been placed in stylesheets/compiled. How do I remove these without them reappeareing after compilation?
  • My own compiled .sass files are compiled to compiled/ts. Why are they in ts and not in compiled?

Many thanks in advance


Edit: Worked it out:

  • No, put them in app/stylesheets/
  • Works if you follow above
  • Remove them from app/stylesheets/
  • Do first answer and they will be put in compiled/
OldTroll
  • 773
  • 6
  • 22
Callum Rogers
  • 15,630
  • 17
  • 67
  • 90

1 Answers1

8

Compass uses a configuration file located in "config/compass.rb" which tells it where the important directories are. I think it knows to look in config/compass.rb because it searches a list of predefined directories for a compass.rb config file

Heres the config file I use for my Rails 3 projects

# This configuration file works with both the Compass command line tool and within Rails.
# Require any additional compass plugins here.
project_type = :rails
project_path = Compass::AppIntegration::Rails.root
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "public/stylesheets"
sass_dir = "app/stylesheets"
images_dir = "public/images"
environment = Compass::AppIntegration::Rails.env
# To enable relative paths to assets via compass helper functions. Uncomment:
# relative_assets = true
preferred_syntax = :sass

I generate this file by running the following command from the Rails root:

compass init rails --css-dir=public/stylesheets --sass-dir=app/stylesheets --images-dir=public/images -x sass --using blueprint/basic

This is the only command that I use to run compass, and I run it when generating my project through a rails template https://github.com/sid137/rails-templates/blob/master/rails3.rb . I constructed this command by reading through the compass help, and looking online, as I wanted to customize all of my compass setup. Now, I can immediately begin my projects with

compass watch .

or

compass compile .
noli
  • 15,927
  • 8
  • 46
  • 62
  • What do you mean by `# Require any additional compass plugins here.`, I'm trying to get compass to work with zurb-foundation, so should I write `require 'zurb-foundation` here or something like that? Thanks. – Daniel Ristic Nov 19 '12 at 14:22
  • Hey, i don't remember exactly what I meant by that (haven't used compass since then) but was probably referring to things such as here: http://compass-style.org/frameworks/ The this plugin, for example, the installation is just as you have described: https://github.com/chriseppstein/compass-colors – noli Nov 19 '12 at 15:40
  • Thanks, I got my answer! To those interested: putting the require for the particular plugin you want to install inside of the file "config/compass.config" or simply "config.rb" at the root of the project (two special places that are searched by default by the compass binary for config settings) will make it available through command line. In my example, when putting `require 'zurb-foundation'` I will be able to use `compass install foundation` from the command line. – Daniel Ristic Nov 19 '12 at 15:57