Location Compass config.rb

I want to add Compass to my existing project. I want to keep the 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 .

Launch:

 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 .

  • How can I control where compass creates the config.rb file?
  • Compass documentation says that declarations in config.rb (e.g. css_dir, sass_dir, etc.) refer to the project_path. Where can I define project_path?
+7
sass compass-sass
source share
3 answers

The compass creates config.rb in the same directory in which you ran the command. The project path is where config.rb is located. You can place config.rb wherever you want, as long as you set up paths for your assets.

+3
source share

This is an example 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 these config.rb settings, your project folder should look like (as you wrote):

 MyFolder โ”œ app โ”œ build โ”‚ โ”” compass โ”‚ โ”” config.rb โ”” assets โ”œ css/ โ”‚ โ”” scss/ โ”œ js โ”” img 

If you do not have config.rb, just create a new file "config.rb" and copy / paste into the configuration I wrote.

Open a terminal, enter MyFolder / build / compass and run the compass command, for example: compass watch


Remember

You must run the compass command in the same folder as the config.rb file. So, in this case, in MyFolder / build / compass. Otherwise, the compass does not work.

+1
source share

I donโ€™t understand why you are structuring a project like this ... I mean, why not put scss in the assembly, and then everything in the assets can be deployed for production?

So: 1. Launch (from the "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 folders and project files as such:

 app |-- build | |--config.rb | |-- compass | |-- scss |-- assets | |-- css | |-- img | |-- js 
  1. Again, from the application directory, do:

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

just create the assembly directory and put the configuration file with these values โ€‹โ€‹in it.

-one
source share

All Articles