Compass config.rb Location

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 assetscssscss and I want to output the compiled CSS files to assetscss .

Running:

compass create --bare --sass-dir "assetscssscss" --css-dir "assetscss"

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

However, I want the file to be under buildcompass .

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

  • 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.


    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.


    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
    
  • 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.

    链接地址: http://www.djcxy.com/p/16324.html

    上一篇: FOSUserBundle:有什么意义?

    下一篇: 指南针config.rb位置