test no fs writing
This commit is contained in:
parent
3b0f3a9a7c
commit
8936e44d00
1 changed files with 0 additions and 27 deletions
|
@ -1,27 +0,0 @@
|
||||||
import * as fs from "fs";
|
|
||||||
|
|
||||||
export default defineNitroPlugin(async () => {
|
|
||||||
console.log("Building registry of custom elements...");
|
|
||||||
const rawKeys = await useStorage().getKeys("/assets/components");
|
|
||||||
const keys = rawKeys.map((key) => key.replace("assets:components:", ""));
|
|
||||||
console.log("Found components:", keys);
|
|
||||||
const imports = keys.map((key, index) => {
|
|
||||||
return `import C${index} from "./${key}"`;
|
|
||||||
});
|
|
||||||
|
|
||||||
const registryObject = `const registry = {
|
|
||||||
${keys
|
|
||||||
.map((key, index) => {
|
|
||||||
const name = key.replace(".js", "").replace(".ts", "");
|
|
||||||
return `"${name}": C${index}`;
|
|
||||||
})
|
|
||||||
.join(",")}}`;
|
|
||||||
|
|
||||||
const customElementsDefine = `Object.keys(registry).forEach((key) => {if(window?.hasOwnProperty("customElements"))customElements.define(key, registry[key]);})`;
|
|
||||||
|
|
||||||
if (!fs.existsSync("./public/.output")) fs.mkdirSync("./public/.output");
|
|
||||||
fs.writeFileSync(
|
|
||||||
"./public/.output/registry.js",
|
|
||||||
[...imports, registryObject, customElementsDefine].join(";")
|
|
||||||
);
|
|
||||||
});
|
|
Loading…
Reference in a new issue