1
|
ABOUT SASS AND COMPASS
|
2
|
----------------------
|
3
|
|
4
|
This directory includes Sass versions of Zen's CSS files.
|
5
|
|
6
|
Sass is a language that is just normal CSS plus some extra features, like
|
7
|
variables, nested rules, math, mixins, etc. If your stylesheets are written in
|
8
|
Sass, helper applications can convert them to standard CSS so that you can
|
9
|
include the CSS in the normal ways with your theme.
|
10
|
|
11
|
To learn more about Sass, visit: http://sass-lang.com
|
12
|
|
13
|
Compass is a helper library for Sass. It includes libraries of shared mixins, a
|
14
|
package manager to add additional extension libraries, and an executable that
|
15
|
can easily convert Sass files into CSS.
|
16
|
|
17
|
To learn more about Compass, visit: http://compass-style.org
|
18
|
|
19
|
|
20
|
DEVELOPING WITH SASS AND COMPASS
|
21
|
--------------------------------
|
22
|
|
23
|
Zen 7.x-5.0 was developed with the latest version of Sass and Compass (at the
|
24
|
time!) Newer versions are not compatible with Zen's Sass files. To ensure you
|
25
|
are using the correct version of Sass and Compass, you will need to use the
|
26
|
"bundle" command which will read Zen's Gemfile to ensure the proper versions are
|
27
|
used when compiling your CSS. To install the correction versions of Sass and
|
28
|
Compass, go to the root directory of your sub-theme and type:
|
29
|
|
30
|
bundle install
|
31
|
|
32
|
You will also need to prefix any compass commands with "bundle exec". For
|
33
|
example, type "bundle exec compass compile" instead of just "compass compile".
|
34
|
|
35
|
To automatically generate the CSS versions of the scss while you are doing theme
|
36
|
development, you'll need to tell Compass to "watch" the sass directory so that
|
37
|
any time a .scss file is changed it will automatically generate a CSS file in
|
38
|
your sub-theme's css directory:
|
39
|
|
40
|
bundle exec compass watch <path to your sub-theme's directory>
|
41
|
|
42
|
If you are already in the root of your sub-theme's directory, you can simply
|
43
|
type: bundle exec compass watch
|
44
|
|
45
|
While using generated CSS with Firebug, the line numbers it reports will not
|
46
|
match the .scss file, since it references the generated CSS file's lines, not
|
47
|
the line numbers of the "source" sass files. How then do we debug? Sourcemaps to
|
48
|
the rescue! To find the oringial, newer browsers have support for sourcemap
|
49
|
files (*.map). These files are used by the built-in development tools of newer
|
50
|
browsers to map the generated line to the SCSS source. When in development mode,
|
51
|
Zen can be set to generate sourcemap files. Edit config.rb, and uncomment:
|
52
|
|
53
|
sourcemap=true
|
54
|
|
55
|
|
56
|
Enabling and using sourcemap files (*.map) in your browser
|
57
|
|
58
|
In short, Open Developer tools, go to settings, and enable an option to the
|
59
|
effect of: 'view original sources' or 'Enable CSS source maps'.
|
60
|
|
61
|
* Firefox: https://hacks.mozilla.org/2014/02/live-editing-sass-and-less-in-the-firefox-developer-tools/
|
62
|
* Chrome: https://developer.chrome.com/devtools/docs/css-preprocessors#toc-enabling-css-source-maps
|
63
|
* IE: http://msdn.microsoft.com/en-US/library/ie/dn255007%28v=vs.85%29#source_maps
|
64
|
|
65
|
|
66
|
MOVING YOUR CSS TO PRODUCTION
|
67
|
-----------------------------
|
68
|
|
69
|
Once you have finished your sub-theme development and are ready to move your CSS
|
70
|
files to your production server, you'll need to tell sass to update all your CSS
|
71
|
files and to compress them (to improve performance). Note: the Compass command
|
72
|
will only generate CSS for .scss files that have recently changed; in order to
|
73
|
force it to regenerate all the CSS files, you can use the Compass' clean command
|
74
|
to delete all the generated CSS files.
|
75
|
|
76
|
- Delete all CSS files by running: bundle exec compass clean
|
77
|
- Edit the config.rb file in your theme's directory and uncomment this line by
|
78
|
deleting the "#" from the beginning:
|
79
|
#environment = :production
|
80
|
- Regenerate all the CSS files by running: bundle exec compass compile
|
81
|
|
82
|
And don't forget to turn on Drupal's CSS aggregation. :-)
|