Skip to content

Instantly share code, notes, and snippets.

@dexbyte
Forked from GottZ/svelte.config.js
Created July 13, 2020 15:55
Show Gist options
  • Save dexbyte/b55747a72f23bc854aaa52a1207df4ff to your computer and use it in GitHub Desktop.
Save dexbyte/b55747a72f23bc854aaa52a1207df4ff to your computer and use it in GitHub Desktop.
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(),
});
},
);
});
},
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment