marksmccann / node-sass-extra

A drop-in replacement for node-sass' Node API that adds support for globs, promises and more.
MIT License
2 stars 1 forks source link

Implement content transformations/dynamic content #7

Open phillipluther opened 5 years ago

phillipluther commented 5 years ago

Allows for transforming file contents pre-compilation in the Node API by means of passing an interator that gets called on the content (string) of every source file.

import sass from 'node-sass-extra';
...
sass('src/**/*.scss', {
    data: contents => contents.replace(/^/, '/* added to file */\n\n')
});
marksmccann commented 5 years ago

What's the difference between this one and #8? Also, do you think that this feature should be included in the initial release? I like it, but I am not 100% convinced it is the right thing to do. I think I would personally vote we hold back on it for now. What do you think?

phillipluther commented 5 years ago

I'm cool holding back on it. Once we have the core functionality in place we can play around with it and find the sweet spot for this functionality.

In my head, the difference between this and #8 is the data/content you receive and can manipulate.

In one version, your iterator would receive the pre-compiled file contents ... the Sass. You could transform that, then pass it along for compilation to CSS.

In the other, your iterator would receive the compiled CSS, which you could transform or replace or mutate.

I'm not sure what value those provide; I just captured that as an idea. I didn't have an answer for, "What would you want to do on the CSS vs. on the Sass?"