Intercept file loading
jhnns opened this issue · 9 comments
Is it possible to intercept the file loading process? So if my main.scss
file contains
@import "grid";
I'd like to load grid
by myself and pass the content to sasslib. Less for example provides a way to override a fileLoader
-function.
I know that node-sass is just a wrapper of libsass. I'm just curious if you know about such an api and if you're providing access to it.
Just for your information: I'm trying to write a sass-loader for webpack which provides loaders and plugins for all kind of "web modules" (html, css, js, less, jade, etc.). webpack needs to know about the dependency tree to work correctly.
I don't believe there is the ability to do that with libsass, node-sass passes includePaths
for places to look for the imports and libsass takes care of the rest. I don't believe libsass has an API for the dependency tree either at the moment.
Ok, thanks. Then I'll ask at libsass 😄
At least they're providing a way to query all imported files. This would be useful for several tools that are using node-sass.
What do you think?
Ah I didn't know that was there, would be good to expose that in node-sass.
A possible api could look like:
var stats = {};
sass.render({
data: 'body{background:blue; a{color:black;}}',
stats: stats,
success: function(css){
console.log(css);
console.log(stats);
}
});
var stats = {};
console.log(sass.renderSync({
data: 'body{background:blue; a{color:black;}}',
stats: stats,
outputStyle: 'compressed'
}));
console.log(stats);
The passed stats
-object would contain information about the compilation (like stats.importedFiles
)
What do you say?
I'll try. Never used a c-binding before 😉