use .output dir
This commit is contained in:
parent
fcc1f999f7
commit
ef2be56efd
6 changed files with 6 additions and 42 deletions
|
@ -5,7 +5,7 @@ export default defineNitroPlugin(async () => {
|
|||
rawKeys.forEach(async (key) => {
|
||||
const cleanKey = key.replace("assets:components:", "");
|
||||
const content = await useStorage().getItem(key);
|
||||
if (!fs.existsSync("./public/output")) fs.mkdirSync("./public/output");
|
||||
fs.writeFileSync(`./public/output/${cleanKey}`, content.toString());
|
||||
if (!fs.existsSync("./public/.output")) fs.mkdirSync("./public/.output");
|
||||
fs.writeFileSync(`./public/.output/${cleanKey}`, content.toString());
|
||||
});
|
||||
});
|
||||
|
|
|
@ -19,11 +19,11 @@ export default defineNitroPlugin(async () => {
|
|||
|
||||
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");
|
||||
if (!fs.existsSync("./public/.output")) {
|
||||
fs.mkdirSync("./public/.output");
|
||||
}
|
||||
fs.writeFileSync(
|
||||
"./public/output/registry.js",
|
||||
"./public/.output/registry.js",
|
||||
[...imports, registryObject, customElementsDefine].join(";")
|
||||
);
|
||||
});
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
import WebComponent from "https://unpkg.com/web-component-base/index.js";
|
||||
|
||||
export default class ClickableText extends WebComponent {
|
||||
onInit() {
|
||||
this.onclick = () => alert("Thank you for clicking the text!");
|
||||
}
|
||||
get template() {
|
||||
return `<span style="cursor:pointer">Click me too!</span>`;
|
||||
}
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
import WebComponent from "https://unpkg.com/web-component-base/index.js";
|
||||
|
||||
export default class HelloWorld extends WebComponent {
|
||||
name = "";
|
||||
static properties = ["name"];
|
||||
|
||||
onInit() {
|
||||
console.log(`Greeting for ${this.name} initialized`);
|
||||
let count = 0;
|
||||
this.onclick = () => {
|
||||
console.log("Clicked!");
|
||||
this.setAttribute("name", `I was clicked ${++count} times`);
|
||||
};
|
||||
this.setAttribute("title", "Click me please");
|
||||
}
|
||||
|
||||
onChanges(changes) {
|
||||
console.log(changes);
|
||||
}
|
||||
|
||||
get template() {
|
||||
return `<button style="cursor:pointer">Hello ${this.name}!</button>`;
|
||||
}
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
import C0 from "./clickable-text.js";import C1 from "./hello-world.js";const registry = {
|
||||
"clickable-text": C0,"hello-world": C1};Object.keys(registry).forEach((key) => {if(window?.hasOwnProperty("customElements"))customElements.define(key, registry[key]);})
|
|
@ -12,7 +12,7 @@ export default eventHandler(async (event) => {
|
|||
|
||||
// temporary; use ultrahtml later
|
||||
const registryScript =
|
||||
'<script type="module" src="./output/registry.js"></script>';
|
||||
'<script type="module" src="./.output/registry.js"></script>';
|
||||
html = html.toString().replace("</head>", registryScript + "</head>");
|
||||
|
||||
return html ?? new Response("Not found", { status: 404 });
|
||||
|
|
Loading…
Reference in a new issue