Skip to content

Instantly share code, notes, and snippets.

@chrismademe
Created December 21, 2021 14:00
Show Gist options
  • Save chrismademe/f44c03b9b67243b190d93975d99e8033 to your computer and use it in GitHub Desktop.
Save chrismademe/f44c03b9b67243b190d93975d99e8033 to your computer and use it in GitHub Desktop.
Compile SCSS in 11ty
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