| 
									
										
										
										
											2015-03-16 21:18:03 +00:00
										 |  |  | --- | 
					
						
							|  |  |  | title: How to use SASS and Compass in Drupal 7 using Sassy | 
					
						
							| 
									
										
										
										
											2020-03-08 14:32:13 +00:00
										 |  |  | date: 2012-12-06 | 
					
						
							| 
									
										
										
										
											2020-03-08 17:52:59 +00:00
										 |  |  | excerpt: | 
					
						
							|  |  |  |   Use PHPSass and the Sassy module to use Sass and Compass in your Drupal theme. | 
					
						
							| 
									
										
										
										
											2015-03-16 21:18:03 +00:00
										 |  |  | tags: | 
					
						
							| 
									
										
										
										
											2015-06-14 03:27:41 +01:00
										 |  |  |   - compass | 
					
						
							|  |  |  |   - css | 
					
						
							|  |  |  |   - drupal | 
					
						
							|  |  |  |   - drupal-7 | 
					
						
							|  |  |  |   - drupal-planet | 
					
						
							|  |  |  |   - less | 
					
						
							|  |  |  |   - preprocessing | 
					
						
							|  |  |  |   - sass | 
					
						
							| 
									
										
										
										
											2015-03-16 21:18:03 +00:00
										 |  |  | --- | 
					
						
							| 
									
										
										
										
											2015-06-18 08:58:56 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-08 17:52:59 +00:00
										 |  |  | I've recently started using [SASS](http://sass-lang.com) rather than LESS to do | 
					
						
							|  |  |  | my CSS preprocessing - namely due to its integration with | 
					
						
							|  |  |  | [Compass](http://compass-style.org) and it's built-in CSS3 mixins. Here are | 
					
						
							|  |  |  | three modules that provide the ability to use SASS within Drupal. | 
					
						
							| 
									
										
										
										
											2015-03-16 21:18:03 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-08 17:52:59 +00:00
										 |  |  | - [Sassy](http://drupal.org/project/sassy 'Sassy module on drupal.org') | 
					
						
							|  |  |  | - [Prepro](http://drupal.org/project/prepro 'Prepro module on drupal.org') | 
					
						
							|  |  |  | - [Libraries API](http://drupal.org/project/libraries 'Libraries API module on drupal.org') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Alternatively, you could use a base theme like | 
					
						
							|  |  |  | [Sasson](http://drupal.org/project/sasson 'Sasson theme on drupal.org') that | 
					
						
							|  |  |  | includes a SASS compiler. | 
					
						
							| 
									
										
										
										
											2015-03-16 21:18:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | ## Download the PHPSass Library
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-08 17:52:59 +00:00
										 |  |  | The first thing to do is download the PHPSass library from | 
					
						
							|  |  |  | [GitHub](https://github.com/richthegeek/phpsass 'PHPSass on GitHub'), as this is | 
					
						
							|  |  |  | a requirement of the Sassy module and we can't enable it without the library. | 
					
						
							|  |  |  | So, in a Terminal window: | 
					
						
							| 
									
										
										
										
											2015-03-16 21:18:03 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-16 08:09:52 +00:00
										 |  |  | ```language-bash | 
					
						
							| 
									
										
										
										
											2020-03-08 17:52:59 +00:00
										 |  |  | $ mkdir -p sites/all/libraries; | 
					
						
							|  |  |  | $ cd sites/all/libraries; | 
					
						
							|  |  |  | $ wget https://github.com/richthegeek/phpsass/archive/master.tar.gz; | 
					
						
							|  |  |  | $ tar zxf master.tar.gz; | 
					
						
							|  |  |  | $ rm master.tar.gz; | 
					
						
							| 
									
										
										
										
											2017-03-16 08:09:52 +00:00
										 |  |  | $ mv phpsass-master/ phpsass | 
					
						
							|  |  |  | ``` | 
					
						
							| 
									
										
										
										
											2015-03-16 21:18:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | Or, if you're using Drush Make files: | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-16 08:09:52 +00:00
										 |  |  | ```language-ini | 
					
						
							|  |  |  | libraries[phpsass][download][type] = "get" | 
					
						
							|  |  |  | libraries[phpsass][download][url] = "https://github.com/richthegeek/phpsass/archive/master.tar.gz" | 
					
						
							|  |  |  | ``` | 
					
						
							| 
									
										
										
										
											2015-03-16 21:18:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | The PHPSass library should now be located at `sites/all/libraries/phpsass`. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ## Download and enable the Drupal modules
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | This is easy if you use [Drush](http://drupal.org/project/drush): | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-16 08:09:52 +00:00
										 |  |  | ```language-bash | 
					
						
							|  |  |  | $ drush dl libraries prepro sassy | 
					
						
							|  |  |  | $ drush en -y libraries prepro sassy sassy_compass | 
					
						
							|  |  |  | ``` | 
					
						
							| 
									
										
										
										
											2015-03-16 21:18:03 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-08 17:52:59 +00:00
										 |  |  | Otherwise, download the each module from it's respective project page and place | 
					
						
							|  |  |  | it within your `sites/all/modules` or `sites/all/modules/contrib` directory. | 
					
						
							| 
									
										
										
										
											2015-03-16 21:18:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | ## Configuring the Prepro module
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-08 17:52:59 +00:00
										 |  |  | The Prepro module provides various settings that can be changed for each | 
					
						
							|  |  |  | preprocessor. Go to `admin/config/media/prepro` to configure the module as | 
					
						
							|  |  |  | required. | 
					
						
							| 
									
										
										
										
											2015-03-16 21:18:03 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-08 17:52:59 +00:00
										 |  |  | Personally, in development, I'd set caching to 'uncached' and the error | 
					
						
							|  |  |  | reporting method to 'show on page'. In production, I'd change these to "cached" | 
					
						
							|  |  |  | and "watchdog" respectively. I'd also set the output style to "compressed", | 
					
						
							| 
									
										
										
										
											2015-03-16 21:18:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | ## Adding SASS files into your theme
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-08 17:52:59 +00:00
										 |  |  | With this done, you can now add SASS and SCSS files by adding a line like | 
					
						
							|  |  |  | `stylesheets[all][] = css/base.scss` in your theme's .info file. |