JSON importer for node-sass. Allows @import
ing .json
files in Sass files parsed by node-sass
.
This module hooks into node-sass's importer api.
var sass = require('node-sass');
var jsonImporter = require('node-sass-json-importer');
// Example 1
sass.render({
file: scss_filename,
importer: jsonImporter,
[, options..]
}, function(err, result) { /*...*/ });
// Example 2
var result = sass.renderSync({
data: scss_content
importer: [jsonImporter, someOtherImporter]
[, options..]
});
Webpack / sass-loader
import jsonImporter from 'node-sass-json-importer';
// Webpack config
export default {
module: {
// Example sass-loader usage.
// See: https://github.com/jtangelder/sass-loader#apply-via-webpack-config
loaders: [{
test: /\.scss$/,
loaders: ["style", "css", "sass"]
}],
},
sassLoader: {
// Apply the JSON importer via sass-loader's options.
importer: jsonImporter
}
};
This module is based on the sass-json-vars gem, which unfortunately isn't compatible with node-sass
.