-
-
Save dimon-durak/32658bdf2adcfe053e8d6a285de13a10 to your computer and use it in GitHub Desktop.
SCSS + PostCSS pipeline for 11ty
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
| // sass dependencies: `npm i -D sass` | |
| const util = require('util'); | |
| const sass = require('sass'); | |
| const renderSass = util.promisify(sass.render); | |
| // postcss dependencies: `npm i -D autoprefixer postcss precss` | |
| const autoprefixer = require('autoprefixer'); | |
| const postcss = require('postcss'); | |
| const precss = require('precss'); | |
| const postcssProcessor = postcss([precss, autoprefixer]); | |
| // file paths | |
| const inputFile = '_includes/main.scss'; | |
| const outputFile = 'style.css'; | |
| module.exports = class { | |
| data() { | |
| return { | |
| permalink: outputFile, | |
| eleventyExcludeFromCollections: true, | |
| }; | |
| } | |
| async render() { | |
| const { css } = await renderSass({ | |
| file: inputFile, | |
| }); | |
| return await postcssProcessor.process(css, { | |
| from: inputFile, | |
| to: outputFile, | |
| }); | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment