csstools / postcss-sass

Use Sass as a PostCSS plugin
Creative Commons Zero v1.0 Universal
139 stars 33 forks source link

Mark all included files as dependencies for watch mode #31

Closed dgreif closed 2 years ago

dgreif commented 2 years ago

This is a fix for https://github.com/csstools/postcss-sass/issues/19. I believe this stems from https://github.com/sass/dart-sass/issues/574 - TL;DR dart-sass does not perfectly match node-sass when it comes to the importer option. In node-sass, all imports are passed to the importer function and can be overridden. This is a feature that postcss-sass was leveraging to gather dependencies for watch mode. However, in dart-sass any imports that can be resolved as a relative path do not get passed to importer. This is why most of our child imports are no longer watched.

The workaround is to do something like sass-loader does here, which is to look at the stats.includedFiles from the dart-sass results, which includes a full list of the files that were encountered during compilation.

Antonio-Laguna commented 2 years ago

@dgreif thanks a lot for taking the time to submit this. Looks sane to me and I'm glad you're leveraging messages to send dependencies!

Will merge and release!

dgreif commented 2 years ago

Thanks @Antonio-Laguna! Glad to see some movement on this project again, really appreciate the recent releases!