-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
50 lines (41 loc) · 1.25 KB
/
index.js
File metadata and controls
50 lines (41 loc) · 1.25 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const postcss = require('postcss');
const tailwindcss = require('tailwindcss');
const fs = require('fs');
const autoprefixer = require('autoprefixer');
const cssnanoPlugin = require('cssnano');
//const data = fs.readFileSync('./styles.css', 'utf8');
const minify = process.argv.includes('--minify');
let temp = process.argv.includes('--output');
const output = temp ? process.argv[process.argv.indexOf('--output')+1] : false;
temp = process.argv.includes('--config');
const config = temp ? process.argv[process.argv.indexOf('--config')+1] : false;
temp = process.argv.includes('--input');
const inputCSS = temp ? process.argv[process.argv.indexOf('--input')+1] : false;
let postcssAddons = [];
if (minify) {
postcssAddons.push(cssnanoPlugin());
}
let tw_config = {
content: ["./src/**/*.html", "./src/**/*.js"],
darkMode: 'class',
theme: {
extend: {},
},
plugins: [],
};
if (config) {
tw_config = require(`${process.cwd()}/${config}`);
}
let css = `
@tailwind base;
@tailwind components;
@tailwind utilities;
`;
if (inputCSS) {
css = fs.readFileSync(inputCSS);
}
postcss([tailwindcss(tw_config), autoprefixer()].concat(postcssAddons))
.process(css)
.then(result => {
fs.writeFileSync(output, result.css)
});