Created
July 5, 2019 19:21
-
-
Save GottZ/4b1b94dec410aae37c688d2529a80e9a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sass = require('node-sass'); | |
// related: https://github.com/UnwrittenFun/svelte-vscode/issues/1 | |
module.exports = { | |
preprocess: { | |
style: async ({ content, attributes }) => { | |
if (!['text/sass', 'text/scss'].some(attributes.type) && !['sass', 'scss'].some(attributes.lang)) return; | |
return new Promise((resolve, reject) => { | |
sass.render( | |
{ | |
data: content, | |
sourceMap: true, | |
outFile: 'x', // this is necessary, but is ignored | |
}, | |
(err, result) => { | |
if (err) return reject(err); | |
resolve({ | |
code: result.css.toString(), | |
map: result.map.toString(), | |
}); | |
}, | |
); | |
}); | |
}, | |
}, | |
}; |
Array.protoype.some takes a callback, not a variable. Maybe replace with Array.prototype.includes.
I actually rewrote that part to a simple string comparison, didn't see the need for fuzzy checking.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks!