Spaces:
Runtime error
Runtime error
File size: 1,041 Bytes
1768d92 |
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 |
import { parse } from "node-html-parser";
import fs from "fs";
// Change the livereload index file to the static built svelte files for publishing.
fs.readFile("../zeno/frontend/index.html", "utf8", (err, data) => {
const index = parse(data);
const body = index.querySelector("body");
const header = index.querySelector("head");
let bodyTags = `<div id="app"></div>`;
let headerTags = ``;
fs.readFile(
"../zeno/frontend/build/manifest.json",
"utf8",
(err, manifest) => {
manifest = JSON.parse(manifest);
Object.values(manifest).forEach((file) => {
if (file.file.endsWith(".js")) {
bodyTags += `<script type="module" src="./build/${file.file}"></script>`;
} else if (file.file.endsWith(".css")) {
headerTags += `<link rel="stylesheet" href="./build/${file.file}">`;
}
});
body.innerHTML = bodyTags;
header.innerHTML = header.innerHTML + headerTags;
fs.writeFileSync("../zeno/frontend/index_tmp.html", index.toString());
}
);
});
|