Created
December 4, 2017 15:16
-
-
Save LasaleFamine/1611c7cef4aa8482a8b8f50939a95c12 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