Created
December 21, 2021 14:00
-
-
Save chrismademe/f44c03b9b67243b190d93975d99e8033 to your computer and use it in GitHub Desktop.
Compile SCSS in 11ty
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('sass'); | |
const cleanCSS = require('clean-css'); | |
module.exports = class { | |
data() { | |
return { | |
layout: false, | |
permalink: '/style.css', | |
eleventyExcludeFromCollections: true, | |
}; | |
} | |
async render() { | |
// Compile SCSS | |
const { css } = sass.renderSync({ | |
file: './assets/sass/style.scss', | |
}); | |
let compiledCSS = css.toString(); | |
compiledCSS = new cleanCSS().minify(compiledCSS).styles; // Minify | |
return compiledCSS; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment