Created
August 3, 2019 04:23
-
-
Save freshyill/24ef9d70f817c793156ec4e5516a1e6d to your computer and use it in GitHub Desktop.
Setting up node-sass directly is needlessly complicated and the documentation sucks.
This file contains 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'); | |
const fs = require('fs'); | |
const scssFile = 'src/site/_includes/scss/style.scss'; | |
const cssFile = 'src/css/style.css'; | |
sass.render({ | |
file: scssFile, | |
sourceMap: true, | |
outputStyle: 'compressed', | |
outFile: cssFile, | |
// importer: function (url, prev, done) { | |
// someAsyncFunction(url, prev, function (result) { | |
// done({ | |
// file: result.path, // only one of them is required, see section Special Behaviours. | |
// }); | |
// }); | |
// // OR | |
// var result = someSyncFunction(url, prev); | |
// return { | |
// file: result.path, | |
// contents: result.data | |
// }; | |
// } | |
}, function (error, result) { // node-style callback from v3.0.0 onwards | |
if (error) { | |
console.log(error.status); // used to be "code" in v2x and below | |
console.log(error.column); | |
console.log(error.message); | |
console.log(error.line); | |
} else { | |
console.log(`\n#########################\nCSS output: \n${result.css.toString()}\n#########################\n`); | |
console.log(result.stats); | |
// console.log(result); | |
// console.log(result.map.toString()); | |
// console.log(JSON.stringify(result.map)); | |
fs.writeFile(cssFile, result.css, function (err) { | |
if (!err) { | |
// console.log('OK it worked?') | |
} | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment