Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Intercept file loading #279

Closed
jhnns opened this issue Apr 8, 2014 · 9 comments
Closed

Intercept file loading #279

jhnns opened this issue Apr 8, 2014 · 9 comments

Comments

@jhnns
Copy link
Contributor

jhnns commented Apr 8, 2014

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.

@andrew
Copy link
Contributor

andrew commented Apr 8, 2014

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.

@jhnns
Copy link
Contributor Author

jhnns commented Apr 8, 2014

Ok, thanks. Then I'll ask at libsass 😄

@jhnns jhnns closed this as completed Apr 8, 2014
@jhnns
Copy link
Contributor Author

jhnns commented Apr 8, 2014

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?

@andrew
Copy link
Contributor

andrew commented Apr 8, 2014

Ah I didn't know that was there, would be good to expose that in node-sass.

@jhnns
Copy link
Contributor Author

jhnns commented Apr 8, 2014

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)

@jhnns
Copy link
Contributor Author

jhnns commented Apr 14, 2014

What do you say?

@andrew
Copy link
Contributor

andrew commented Apr 14, 2014

@jhnns sounds good, would you be up for sending a pull request for this?

@jhnns
Copy link
Contributor Author

jhnns commented Apr 14, 2014

I'll try. Never used a c-binding before 😉

@jhnns
Copy link
Contributor Author

jhnns commented Oct 7, 2014

Btw: At libsass they're currently discussing an API for this feature #21

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants