Installation de SASS et COMPASS en ligne de commande
- SASS : (procédure d’installation officielle) http://sass-lang.com/install
- COMPASS : (procédure d’installation officielle) http://compass-style.org/install/
Configuration projet
Pour initialiser SASS, taper à la racine du répertoire qui contient le dossier CSS :
1 |
$ compass init |
Cette commande va, par défaut, créer un fichier config.rb et des répertoires et des fichiers de base dans lesquels seront stockés vos fichiers SASS et les CSS générées.
Editer le fichier config.rb en fonction de votre propre organisation en terme de fichiers et supprimez les fichiers et répertoires par défaut qui vous sont inutiles.
Exemple pour un thème Change :
- Editer les chemins (paths) vers les répertoires qui stockent vous fichiers css, sass, images, js…
- Passer line_comments à true
- Passer output_style à :expanded (mode dev)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
require 'compass/import-once/activate' # Require any additional compass plugins here. # Set this to the root of your project when deployed: http_path = "/" css_dir = "style" sass_dir = "scss" images_dir = "image" javascripts_dir = "js" # 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 enable relative paths to assets via compass helper functions. Uncomment: # relative_assets = true # To disable debugging comments that display the original location of your selectors. Uncomment: line_comments = true # If you prefer the indented syntax, you might want to regenerate this # project again passing --syntax sass, or you can uncomment this: # preferred_syntax = :sass # and then run: # sass-convert -R --from scss --to sass sass scss && rm -rf sass && mv scss sass |
Votre arborescence (toujours pour un thème Change) devrait ressembler à ceci :
Pour lancer la génération automatique des fichiers CSS à partir des fichiers SASS, rendez-vous à la racine de votre thème (dans le répertoire où se trouve le fichier config.rb) :
1 |
$ compass watch |
Troubleshooting
/usr/lib/ruby/vendor_ruby/bundler/rubygems_ext.rb:8:in `require’: no such file to load — rubygems (LoadError)
I have a hunch that you have two ruby versions. Please paste the output of following command:
1 |
$ which -a ruby |
Nuke one version and leave only one. I had same problem with two versions looking at different locations for gems. Had me going crazy for few weeks. Put up a bounty here at SO got me same answer I’m giving to you.
All I did was nuke one installation of ruby and left the one managable via ports. I’d suggest doing this:
- Remove ruby version installed via ports (yum or whatever package manager).
- Remove ruby version that came with OS (hardcore rm by hand).
- Install ruby version from ports with different prefix (/usr instead of /usr/local)
- Reinstall rubygems
Could not find rake-10.0.4 in any of the sources
Sometimes we doesn’t get response from http://rubygems.org/ so it will shows error again try
1 |
gem install rake |
to install latest version (10.0.4) of rake, and next
1 |
bundle update rake |
to update the Gemfile.lock
LoadError on line 70 of /usr/lib/ruby/vendor_ruby/sass/../compass/commands/watch_project.rb: no such file to load — fssm
1 |
sudo apt-get -uVf install libfssm-ruby |
Failed to build gem native extension (installing Compass)
Essayer ceci, puis ré-essayer d’installer compass :
1 |
sudo apt-get install ruby-dev |
Failed to build gem native extension
Erreur : sh: make: not found lors de l’install de compass.
1 2 3 4 5 6 7 8 9 |
Building native extensions. This could take a while... ERROR: Error installing rails: ERROR: Failed to build gem native extension. /usr/bin/ruby1.8 extconf.rb creating Makefile make sh: make: not found |
Installer le package build-essential :
1 |
apt-get install build-essential |