-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathremove-assets.js
39 lines (35 loc) · 1014 Bytes
/
remove-assets.js
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
/* A simple Node script to remove the not required asset files from the build folder after the build process. */
const fs = require("fs");
const path = require("path");
const filesToRemove = [
"admin.asset.php",
"front.asset.php",
"style-blocks.css",
"blocks.css",
];
filesToRemove.forEach((file) => {
fs.unlink(path.join(__dirname, "build", file), (err) => {
if (err) {
console.error(`Failed to remove ${file}:`, err);
} else {
console.log(`Successfully removed ${file}`);
}
});
});
const filesToRename = {
"style-blocks.css": "style-index.css",
"blocks.css": "index.css",
};
for (const [oldName, newName] of Object.entries(filesToRename)) {
fs.rename(
path.join(__dirname, "build/blocks", oldName),
path.join(__dirname, "build/blocks", newName),
(err) => {
if (err) {
console.error(`Failed to rename ${oldName} to ${newName}:`, err);
} else {
console.log(`Successfully renamed ${oldName} to ${newName}`);
}
}
);
}