docpad / docpad-plugin-sass

Adds support for the SASS and SCSS CSS pre-processors to DocPad. It also supports the Compass framework.
Other
13 stars 6 forks source link

sass globbing #22

Closed gmhenderson closed 10 years ago

gmhenderson commented 11 years ago

I am trying to use sass-globbing (https://github.com/chriseppstein/sass-globbing) but adding it to the requireLibraries option isn't working. Is there any reason it wouldn't work? Or is it more likely there's an issue with my ruby environment?

gmhenderson commented 11 years ago

My docpad.coffee contains:

plugins:
    sass:
        requireLibraries: ['sass-globbing']

My import line looks like @import "modules/**/*"; with which I get the following error:

error: An error occured: 
Error: Syntax error: File to import not found or unreadable: modules/**/*.
              Load paths:
                /httpdocs/test
                /httpdocs/test/src/documents/styles
                /httpdocs/test/sass
                /usr/local/Cellar/ruby/2.0.0-p0/lib/ruby/gems/2.0.0/gems/compass-0.12.2/frameworks/blueprint/stylesheets
                /usr/local/Cellar/ruby/2.0.0-p0/lib/ruby/gems/2.0.0/gems/compass-0.12.2/frameworks/compass/stylesheets
                Compass::SpriteImporter
                Sass::Globbing::Importer
        on line 3 of standard input
  Use --trace for backtrace.

    at ChildProcess.<anonymous> (/httpdocs/test/node_modules/docpad-plugin-sass/node_modules/safeps/out/lib/safeps.js:159:23)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:735:16)
    at Socket.<anonymous> (child_process.js:948:11)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Pipe.close (net.js:466:12)

Any ideas?

matthew-andrews commented 10 years ago

This is being caused by various reasons - by default docpad-plugin-sass passes the contents of the sass/scss files into sass via --stdin - which sass-globbing currently doesn't support (see issue referenced above). It's possible to hack in support for it in that library - but if you do that you'll need to also change the way docpad-plugin-sass.

It is possible to change that default behiavour to make docpad-plugin-sass pass the filename into sass instead by setting sourcemap: true - this happens on this line of code: https://github.com/docpad/docpad-plugin-sass/blob/master/src/sass.plugin.coffee#L100.

However, that is currently broken because of a tiny error on this line of code https://github.com/docpad/docpad-plugin-sass/blob/master/src/sass.plugin.coffee#L102. Array#push returns an integer, not the same array again - which then means subsequent command.pushs fail.

I've made a pull request to fix this Someone has made a pull request to fix this here: https://github.com/docpad/docpad-plugin-sass/pull/27. So a temporary workaround could be to use a fork where that is fixed npm install --save git://github.com/matthew-andrews/docpad-plugin-sass and set sourcemap:true in the sass plugin settings of your docpad.js/json/coffee file.

matthew-andrews commented 10 years ago

OK since @balupton release this morning (v2.7.2) this now works (so no need to use my fork) if you put the following settings in the docpad file:-

plugins:
  sass:
    sourcemap: true
    requireLibraries: ['sass-globbing']

(sourcemap:true required to work around this bug in the sass-globbing library: https://github.com/chriseppstein/sass-globbing/issues/14)

balupton commented 10 years ago

Sweet, I'll close.

gmhenderson commented 10 years ago

Thank you.