Skip to content

Instantly share code, notes, and snippets.

@LasaleFamine
Created December 4, 2017 15:16
Show Gist options
  • Save LasaleFamine/1611c7cef4aa8482a8b8f50939a95c12 to your computer and use it in GitHub Desktop.
Save LasaleFamine/1611c7cef4aa8482a8b8f50939a95c12 to your computer and use it in GitHub Desktop.
Building postcss files.
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