angular ui
This commit is contained in:
37
tools/generateAssetManifest.js
Normal file
37
tools/generateAssetManifest.js
Normal file
@@ -0,0 +1,37 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
const basePath = path.join(__dirname, "../src/assets");
|
||||
|
||||
function detectType(filepath) {
|
||||
const ext = path.extname(filepath).toLowerCase();
|
||||
if ([".svg", ".png", ".jpg"].includes(ext)) return "image";
|
||||
if ([".mp3", ".ogg", ".wav"].includes(ext)) return "audio";
|
||||
return "other";
|
||||
}
|
||||
|
||||
function walk(dir, acc = []) {
|
||||
const entries = fs.readdirSync(dir);
|
||||
for (const entry of entries) {
|
||||
const fullPath = path.join(dir, entry);
|
||||
const relPath = path.relative(basePath, fullPath).replace(/\\/g, "/");
|
||||
const stat = fs.statSync(fullPath);
|
||||
|
||||
if (stat.isDirectory()) {
|
||||
walk(fullPath, acc);
|
||||
} else {
|
||||
acc.push({
|
||||
path: relPath,
|
||||
type: detectType(fullPath),
|
||||
size: stat.size,
|
||||
});
|
||||
}
|
||||
}
|
||||
return acc;
|
||||
}
|
||||
|
||||
const assets = walk(basePath);
|
||||
fs.writeFileSync(
|
||||
path.join(basePath, "manifest.json"),
|
||||
JSON.stringify(assets, null, 2)
|
||||
);
|
||||
Reference in New Issue
Block a user