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

Stylesheet not regenerating when imported underscore stylesheet is saved #13

Open jstcki opened 11 years ago

jstcki commented 11 years ago

I have something like

// a.css.scss
import "b";
body {
  color: $text-color;
}

and

// _b.scss
$text-color: red;

When I change _b.scss, a.css doesn't get regenerated. I have to manually save a.css.scss, in order for a.css to be updated.

pflannery commented 11 years ago

I have a similar issue.

I have a screen.css.scss file (see it here) that contains imports to a bunch of scss files. Problem is that changing any of the imports doesn't refresh the screen.css output file. In order to refresh it you have amened and resave the screen.css.scss file to cause sass to recompile.

I have a workaround for the time being. I created a query on the database that sets the referenceOthers = true on all of my import scss files This way when a change occurs it forces sass to recompile.

Query example:

    sassWatchQuery =                     
            fullPath: 
                $startsWith: sassDirPath # put your root sass path here
            extension: 
                $in: ['scss', 'sass']

    # Monitor for changes on sass files so we can cause sass to recompile
    docpad.getDatabase()
            .findAllLive(sassWatchQuery)
            .on('add', (model) ->
                # referencesOthers tells docpad that these files reference other documents
                # therefore when a change happens to one of them it forces it to recompile
                # which in turn will rebuild the output css files
                model.referencesOthers( true)
            )
balupton commented 11 years ago

That's strange that you have to do that, as in the core we already do it https://github.com/bevry/docpad/blob/30c2fe94e26cf7f554bcc06d9f332e444e7f84d2/src/lib/docpad.coffee#L1722-L1739

Perhaps our code is broken... Perhaps the following eco code would work on finding out:

<pre><%- JSON.stringify @getCollection('stylesheet`).pluck('fullPath') %></pre>
pflannery commented 11 years ago

ah, I see why now... Its not docpad's code, it's because all my sass files live in the partials folder at the moment. (I hope to move them to their own folder at some point in the future)

I've changed my code to use isFile = true

    .on('add', (model) ->
                    # isFile tells docpad that these files should be monitored
                    model.attributes.isFile = true
                )

great, thanks...

balupton commented 11 years ago

Cool, glad you got it sorted. Out of curiosity, how come you have your sass files inside the partials directory?

pflannery commented 11 years ago

Bascially the oocss framework has a unique way of being built and it has a custom parser that generates documentation, tests and css from all of the components. None of the component files here should be written or rendered to the out. Just the final css, docs and test files get put in out.

I may plan on putting them else where in future but for now partials was the easiest place to put them whist I'm porting the parser code over to docpad