-
Notifications
You must be signed in to change notification settings - Fork 111
/
.cssnext
34 lines (27 loc) · 964 Bytes
/
.cssnext
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env node
// Compile folder of `.css` files.
// Remove this when issue will be resolved:
// https://github.com/cssnext/cssnext/issues/93
const fs = require('fs');
const path = require('path');
const postcss = require('postcss');
const postcssCssnext = require('postcss-cssnext');
const postcssImport = require('postcss-import');
const inputFolderPath = 'src/cssnext/';
const outputFolderPath = 'styles/';
const cssnextPath = path.join(__dirname, inputFolderPath);
fs.readdir(cssnextPath, function (err, files) {
if (err) {
throw err;
}
files.forEach(function (file) {
console.log('%s -> %s', inputFolderPath+file, outputFolderPath+file);
const input = fs.readFileSync(path.join(cssnextPath, file), 'utf8');
postcss([postcssImport, postcssCssnext])
.process(input)
.then(function (result) {
fs.writeFileSync(path.join(__dirname, outputFolderPath+file), result.css);
});
});
console.log(' ');
});