I have been using compass with a nanoc site. However, I don't even
try to integrate it with nanoc, I simply use a rake task to run
compass -u and copy the generated css files into the nanoc
output directory.
If anyone does come up with a way to use compass directly from within
nanoc, I would sure love to hear about it.
Here's how I read it:
Instead of putting the config information directly into nanoc's Rules
file, it's better to parse an external config file. This means both the
Compass command line utility and nanoc are reading the same config. This
means you don't have to change your config in two places (staying DRY
and all that).
Chris, please correct me if I'm wrong on this.
Here's an example of my nanoc Rules file (my Compass config.rb file is
in <my_nanoc_project/compass/config.rb>):
#!/usr/bin/env ruby
require 'compass'
Compass.configuration.parse 'compass/config.rb'
compile '/assets/style/*/' do
filter :sass, Compass.sass_engine_options
end
route '/assets/style/*/' do
item.identifier.chop + '.css'
end
compile '*' do
filter :erb
layout 'default'
end
route '*' do
item.identifier + 'index.html'
end
layout '*', :erb
Forgot to post the content of my config.rb - it's really simple:
require 'susy'
# Require any additional compass plugins here.
project_type = :stand_alone
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "../output/stylesheets"
sass_dir = "src"
images_dir = "../output/images"
output_style = :compact
# To enable relative paths to assets via compass helper functions.
Uncomment:
# relative_assets = true
require 'compass'
Compass.configuration.parse 'compass/config.rb'
compile '/assets/style/*/' dofilter :sass, Compass.sass_engine_optionsend
route '/assets/style/*/' do
item.identifier.chop + '.css'
end
compile '*' do
filter :erb
layout 'default'
end
route '*' do
item.identifier + 'index.html'
end
layout '*', :erb
require 'susy'
# Require any additional compass plugins here.
project_type = :stand_alone
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "../output/stylesheets"
sass_dir = "src"
images_dir = "../output/images"
output_style = :compact
# To enable relative paths to assets via compass helper functions.
Uncomment:
# relative_assets = true
Diego, are you using an older version of nanoc? The default layout I'm
getting is different. You need to do "gem install nanoc3" for the
latest version.
Chris, I'll be posting a screenshot shortly of how I've setup a nanoc
site. I'm currently struggling with the same issue I had previously
with Staticmatic, that being, it doesn't seem to be able to cope with
partials.
I've posted on the nanoc group to see if I can work out what's going
on with that for sure.
Charles
Chris,
This screenshot should provide the info you need. I've not placed the
Compass config where you recommend but instead I've placed it in the
nanoc project root. Compass seems to compile fine in this setup.
http://i34.tinypic.com/9zn686.jpg
The trick to making nanoc compile sass files is to add an empty yaml
file of the same name. The screenshot should illustrate it.
Here's the question I posed on the nanoc group:
http://groups.google.com/group/nanoc/browse_thread/thread/f92aa2a80a3d5a8d
Charles
route 'something' do
if File.basename(item.identifier)[0..0] == "_"
nil else #compile it end
end
I wonder if there is some other problem going on then. Here's what I've got now:
compile '/stylesheets/*/' do
if File.basename(item.identifier)[0..0] == "_"
nil
else
filter :sass, Compass.sass_engine_options
end
end
But this is what happens when I compile:
> nanoc3 compile
Loading site data...
Compiling site...
+--- /!\ ERROR /!\ -------------------------------------------+
| An exception occured while running nanoc. If you think this |
| is a bug in nanoc, please do report it at |
| <http://projects.stoneship.org/trac/nanoc/newticket> -- |
| thanks in advance! |
+-------------------------------------------------------------+
=== MESSAGE:
Sass::SyntaxError: File to import not found or unreadable: base.sass.
=== COMPILATION STACK:
- [item] /stylesheets/ie/ (rep default)
=== BACKTRACE:
0. item /stylesheets/ie/ (rep default):9
1. C:/Users/charlesr/Tools/Ruby/Ruby186/lib/ruby/gems/1.8/gems/haml-2.2.6/lib/sass/tree/import_node.rb:53:in
`import'
2. C:/Users/charlesr/Tools/Ruby/Ruby186/lib/ruby/gems/1.8/gems/haml-2.2.6/lib/sass/tree/import_node.rb:33:in
`perform!'
3. C:/Users/charlesr/Tools/Ruby/Ruby186/lib/ruby/gems/1.8/gems/haml-2.2.6/lib/sass/tree/node.rb:179:in
`_perform'
4. C:/Users/charlesr/Tools/Ruby/Ruby186/lib/ruby/gems/1.8/gems/haml-2.2.6/lib/sass/tree/node.rb:156:in
`perform'
5. C:/Users/charlesr/Tools/Ruby/Ruby186/lib/ruby/gems/1.8/gems/haml-2.2.6/lib/sass/tree/node.rb:200:in
`perform_children'
6. C:/Users/charlesr/Tools/Ruby/Ruby186/lib/ruby/gems/1.8/gems/haml-2.2.6/lib/sass/tree/node.rb:200:in
`map'
7. C:/Users/charlesr/Tools/Ruby/Ruby186/lib/ruby/gems/1.8/gems/haml-2.2.6/lib/sass/tree/node.rb:200:in
`perform_children'
8. C:/Users/charlesr/Tools/Ruby/Ruby186/lib/ruby/gems/1.8/gems/haml-2.2.6/lib/sass/tree/node.rb:191:in
`perform!'
9. C:/Users/charlesr/Tools/Ruby/Ruby186/lib/ruby/gems/1.8/gems/haml-2.2.6/lib/sass/tree/node.rb:179:in
`_perform'
10. C:/Users/charlesr/Tools/Ruby/Ruby186/lib/ruby/gems/1.8/gems/haml-2.2.6/lib/sass/tree/node.rb:156:in
`perform'
11. C:/Users/charlesr/Tools/Ruby/Ruby186/lib/ruby/gems/1.8/gems/haml-2.2.6/lib/sass/tree/node.rb:103:in
`render'
12. C:/Users/charlesr/Tools/Ruby/Ruby186/lib/ruby/gems/1.8/gems/haml-2.2.6/lib/sass/engine.rb:148:in
`render'
13. C:/Users/charlesr/Tools/Ruby/Ruby186/lib/ruby/gems/1.8/gems/nanoc3-3.0.1/lib/nanoc3/filters/sass.rb:13:in
`run'
14. C:/Users/charlesr/Tools/Ruby/Ruby186/lib/ruby/gems/1.8/gems/nanoc3-3.0.1/lib/nanoc3/base/item_rep.rb:166:in
`filter'
15. C:/Users/charlesr/Tools/Ruby/Ruby186/lib/ruby/gems/1.8/gems/nanoc3-3.0.1/lib/nanoc3/base/rule_context.rb:51:in
`filter'
16. (eval):10:in `load_rules'
17. C:/Users/charlesr/Tools/Ruby/Ruby186/lib/ruby/gems/1.8/gems/nanoc3-3.0.1/lib/nanoc3/base/rule.rb:32:in
`instance_eval'
18. C:/Users/charlesr/Tools/Ruby/Ruby186/lib/ruby/gems/1.8/gems/nanoc3-3.0.1/lib/nanoc3/base/rule.rb:32:in
`apply_to'
19. C:/Users/charlesr/Tools/Ruby/Ruby186/lib/ruby/gems/1.8/gems/nanoc3-3.0.1/lib/nanoc3/base/compiler.rb:175:in
`compile_rep'
20. C:/Users/charlesr/Tools/Ruby/Ruby186/lib/ruby/gems/1.8/gems/nanoc3-3.0.1/lib/nanoc3/base/compiler.rb:121:in
`compile_reps'
21. C:/Users/charlesr/Tools/Ruby/Ruby186/lib/ruby/gems/1.8/gems/nanoc3-3.0.1/lib/nanoc3/base/compiler.rb:70:in
`run'
22. C:/Users/charlesr/Tools/Ruby/Ruby186/lib/ruby/gems/1.8/gems/nanoc3-3.0.1/lib/nanoc3/cli/commands/compile.rb:84:in
`run'
23. C:/Users/charlesr/Tools/Ruby/Ruby186/lib/ruby/gems/1.8/gems/nanoc3-3.0.1/vendor/cri/lib/cri/base.rb:91:in
`run'
24. C:/Users/charlesr/Tools/Ruby/Ruby186/lib/ruby/gems/1.8/gems/nanoc3-3.0.1/lib/nanoc3/cli/base.rb:55:in
`run'
25. C:/Users/charlesr/Tools/Ruby/Ruby186/lib/ruby/gems/1.8/gems/nanoc3-3.0.1/bin/nanoc3:16
26. C:/Users/charlesr/Tools/Ruby/Ruby186/bin/nanoc3:19:in `load'
27. C:/Users/charlesr/Tools/Ruby/Ruby186/bin/nanoc3:19
Aaaah, that got it. I had set project_root, instead of project_path. Doh.
Here's what my config.rb (compass config) now looks like:
require 'susy'
# Require any additional compass plugins here.
project_type = :stand_alone
# Set this to the root of your project when deployed:
http_path = "/"
project_path = "."
css_dir = "output/stylesheets"
sass_dir = "content/stylesheets"
images_dir = "output/stylesheets"
output_style = :compact
# To enable relative paths to assets via compass helper functions. Uncomment:
# relative_assets = true
And this is my Rules file (note how I don't need to use the ignore
partials trick you mentioned earlier; that's because nanoc ignores
files without a companion yaml file.)
#!/usr/bin/env ruby
require 'compass'
Compass.configuration.parse 'config.rb'
compile '/stylesheets/*/' do
filter :sass, Compass.sass_engine_options
end
route '/stylesheets/*/' do
Some further thoughts on Sass integration from Denis over on the nanoc group:
http://groups.google.com/group/nanoc/browse_thread/thread/f92aa2a80a3d5a8d
Charles