-
-
Save equinusocio/2e662187c68bff2e9a71f00455ef86bd to your computer and use it in GitHub Desktop.
Building postcss files.
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
| const fs = require('fs-extra'); | |
| const postcss = require('postcss'); | |
| const postcssrc = require('postcss-load-config'); | |
| const folder = './folder/'; | |
| const outputFolder = './out'; | |
| const run = async () => { | |
| const files = await fs.readdir(folder); | |
| files.forEach(async file => { | |
| const fileContent = await fs.readFile(`${folder}/${file}`, 'utf8'); | |
| const {css} = await postcssrc().then(({plugins}) => postcss(plugins).process(fileContent)); | |
| await fs.ensureDir(outputFolder); | |
| await fs.writeFile(`${outputFolder}/${file.replace('postcss', 'css')}`, css); | |
| }); | |
| } | |
| run().catch(err => console.error(err)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment