Open antixrist opened 8 years ago
I use it for custom url resolver. Example:
// ... .pipe(gulpSass({ precision: 10, importer: require('node-sass-import-once'), importOnce: { index: true, css: true, bower: false, /** * It's new option * * @param {string} filename * @param {string} contents * @returns {string} */ transformContent: function (filename, contents) { return [ '$__filepath: unquote("'+ filename +'");', '@function url($url: null, $args...) {', ' @return __url($__filepath, $url);', '}', contents ].join('\n'); } }, functions: { '__url($filepath, $url)': function(filepath, url, done) { url = url.getValue(); filepath = filepath.getValue(); var resolvedUrl = url; /* ...custom url resolve here... */ done(new sass.types.String('url('+ resolvedUrl +')')); }, } })) // ...
I use it for custom url resolver. Example: