33 lines
982 B
JavaScript
33 lines
982 B
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
const { execSync } = require('child_process');
|
|
|
|
const CSS_SRC = path.join(__dirname, 'css', 'style.css');
|
|
const CSS_OUT = path.join(__dirname, 'css', 'output.css');
|
|
const TAILWIND_CLI = path.join(__dirname, '..', '..', '..', '..', 'apxtri', 'node_modules', '@tailwindcss', 'cli', 'dist', 'index.mjs');
|
|
|
|
var lastCompile = 0;
|
|
|
|
function compileCSS() {
|
|
var cmd = process.execPath + ' "' + TAILWIND_CLI + '" -i "' + CSS_SRC + '" -o "' + CSS_OUT + '" --minify';
|
|
try {
|
|
execSync(cmd, { stdio: 'inherit' });
|
|
lastCompile = Date.now();
|
|
console.log('[' + new Date().toLocaleTimeString() + '] CSS compiled');
|
|
} catch (e) {
|
|
console.error('CSS compile error:', e.message);
|
|
}
|
|
}
|
|
|
|
console.log('Watching ' + CSS_SRC + ' for changes...');
|
|
compileCSS();
|
|
|
|
fs.watch(CSS_SRC, function (eventType) {
|
|
if (eventType === 'change') {
|
|
var now = Date.now();
|
|
if (now - lastCompile > 500) {
|
|
compileCSS();
|
|
}
|
|
}
|
|
});
|