-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclean-css.js
More file actions
28 lines (24 loc) · 752 Bytes
/
Copy pathclean-css.js
File metadata and controls
28 lines (24 loc) · 752 Bytes
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
const fs = require("fs");
const path = require("path");
// Directory containing the CSS files
const cssDir = path.join(__dirname, "build/static/css");
fs.readdir(cssDir, (err, files) => {
if (err) {
console.error("Error reading CSS directory:", err);
return;
}
// Filter out the main CSS file (assuming it starts with 'main.' and ends with '.css')
const filesToDelete = files.filter(
(file) => !(file.startsWith("main.") && file.endsWith(".css"))
);
filesToDelete.forEach((file) => {
const filePath = path.join(cssDir, file);
fs.unlink(filePath, (err) => {
if (err) {
console.error(`Error deleting file: ${file}`, err);
} else {
console.log(`Deleted: ${file}`);
}
});
});
});