Use PostCSS for bundling
This commit is contained in:
46
scripts/bundle-css.js
Normal file
46
scripts/bundle-css.js
Normal file
@@ -0,0 +1,46 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
// Define the CSS files to bundle in order
|
||||
const cssFiles = [
|
||||
'static/assets/plugins/bootstrap/bootstrap.min.css',
|
||||
'static/assets/css/theme.css',
|
||||
'static/assets/plugins/bootstrap-icons/bootstrap-icons.css',
|
||||
'static/assets/plugins/font-awesome/css/all.css'
|
||||
];
|
||||
|
||||
// Output file
|
||||
const outputFile = 'static/assets/css/bundle.min.css';
|
||||
|
||||
// Function to bundle CSS files
|
||||
function bundleCSS() {
|
||||
let bundledCSS = '';
|
||||
|
||||
console.log('Starting CSS bundling...');
|
||||
|
||||
cssFiles.forEach(file => {
|
||||
const filePath = path.join(__dirname, '..', file);
|
||||
console.log(`Processing: ${filePath}`);
|
||||
|
||||
if (fs.existsSync(filePath)) {
|
||||
const content = fs.readFileSync(filePath, 'utf8');
|
||||
bundledCSS += `\n/* === ${file} === */\n${content}\n`;
|
||||
console.log(`✓ Added: ${file}`);
|
||||
} else {
|
||||
console.warn(`⚠ Warning: ${file} not found`);
|
||||
}
|
||||
});
|
||||
|
||||
// Ensure output directory exists
|
||||
const outputDir = path.dirname(outputFile);
|
||||
if (!fs.existsSync(outputDir)) {
|
||||
fs.mkdirSync(outputDir, { recursive: true });
|
||||
}
|
||||
|
||||
// Write bundled CSS
|
||||
fs.writeFileSync(path.join(__dirname, '..', outputFile), bundledCSS);
|
||||
console.log(`✓ Bundled CSS saved to: ${outputFile}`);
|
||||
}
|
||||
|
||||
// Run the bundling
|
||||
bundleCSS();
|
||||
Reference in New Issue
Block a user