7
votes

I want to add Compass to my existing project. I want to maintain my current project structure, which looks like this (simplified):

app/
build/    
 |-compass/
assets/
 |-css/
   |-scss
 |-js/
 |-img/

So I want all my SASS files under \assets\css\scss and I want to output the compiled CSS files to \assets\css.

Running:

compass create --bare --sass-dir "assets\css\scss" --css-dir "assets\css"

creates the Compass config.rb file directly under my root.

However, I want the file to be under \build\compass.

  1. How can I control where Compass creates the config.rb file?
  2. Compass documentation says that declarations in config.rb (e.g. css_dir, sass_dir, etc.) are all relative to the project_path. Where do I define the project_path?
3

3 Answers

3
votes

Compass creates the config.rb in the same directory as where you ran the command from. The project path is where the config.rb resides. You're free to place config.rb wherever you like, as long as you adjust the paths for your assets.

1
votes

This is an example of config.rb:

# Require any additional compass plugins here.
require 'compass/import-once/activate'

# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "../../assets/css"
sass_dir = "../../assets/css/scss"

# You can select your preferred output style here (can be overridden via the command line):
# output_style = :expanded or :nested or :compact or :compressed
output_style = :expanded

# To disable debugging comments that display the original location of your selectors. Uncomment:
line_comments = false

# Enable source map
sourcemap = true

And with this config.rb settings, your project folder should be like (as you wrote):

MyFolder
├ app
├ build 
│ └ compass
│   └ config.rb
└ assets
  ├ css/
  │ └ scss/
  ├ js
  └ img

If you don't have a config.rb, simply create a new file "config.rb" and copy/paste inside the configuration i wrote.

Open your terminal, enter in MyFolder/build/compass and then start your compass command, like: compass watch


Remember

You have to execute your compass command in the same folder where is the config.rb file. So in this case in MyFolder/build/compass. Otherwise compass doesn't work.

-1
votes

I don't see why you'd structure a project like this...I mean why not put the scss in build and then everything in assets can be deployed for production?

So: 1. Running (from "app" directory)

compass create build --http-pat="../" --sass-dir="compass/scss" --css-dir="../assets/css" --javascripts-dir="../assets/js" --images-dir="../assets/img"

will create the project folders and files as such:

app
 |-- build
 |     |--config.rb
 |     |-- compass
 |            |-- scss
 |-- assets
 |     |-- css
 |     |-- img
 |     |-- js
  1. Again, from within app directory, running:

compass config "build/config.rb" --http-pat="../" --sass-dir="compass/scss" --css-dir="../assets/css" --javascripts-dir="../assets/js" --images-dir="../assets/img"

will simply create the build directory and place a configuration file with these values in it.