html-bundle 5.5.0 → 6.0.1-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bundle.js DELETED
@@ -1,625 +0,0 @@
1
- #!/usr/bin/env node
2
- import fs from "fs";
3
- import { performance } from "perf_hooks";
4
- import Event from "events";
5
- import glob from "glob";
6
- import path from "path";
7
- import Fastify from "fastify";
8
- import fastifyStatic from "fastify-static";
9
- import postcss from "postcss";
10
- import postcssrc from "postcss-load-config";
11
- import cssnano from "cssnano";
12
- import esbuild from "esbuild";
13
- import critical from "critical";
14
- import { minify } from "html-minifier-terser";
15
- import { watch } from "chokidar";
16
- import { serialize, parse, parseFragment } from "parse5";
17
- import { createScript, getTagName, appendChild, findElement, findElements, } from "@web/parse5-utils";
18
- // CLI and options
19
- const isCritical = process.argv.includes("--critical");
20
- const isHMR = process.argv.includes("--hmr");
21
- const isCSP = process.argv.includes("--csp");
22
- const isSecure = process.argv.includes("--secure");
23
- const isServeOnly = process.argv.includes("--serveOnly");
24
- let fastify;
25
- if (isServeOnly) {
26
- createDefaultServer();
27
- fastify.listen(5000);
28
- console.log(`💻 Sever listening on port 5000.`);
29
- }
30
- else {
31
- process.env.NODE_ENV = isHMR ? "development" : "production";
32
- let { plugins, options, file } = createPostCSSConfig();
33
- let CSSprocessor = postcss(plugins);
34
- // Performance Observer and file watcher
35
- const globHTML = new Event.EventEmitter();
36
- const taskEmitter = new Event.EventEmitter();
37
- let start = performance.now();
38
- let addedHMR = false;
39
- let expectedTasks = 0; // This will be increased in globHandlers
40
- let finishedTasks = 0; // Current status
41
- taskEmitter.on("done", () => {
42
- finishedTasks++;
43
- if (finishedTasks === expectedTasks) {
44
- console.log(`🚀 Build finished in ${(performance.now() - start).toFixed(2)}ms ✨`);
45
- if (isHMR && !addedHMR) {
46
- addedHMR = true;
47
- if (file) {
48
- const postCSSWatcher = watch(file);
49
- const tailwindCSSWatcher = watch(file.replace("postcss", "tailwind"));
50
- postCSSWatcher.on("change", () => rebuildCSS("postcss"));
51
- tailwindCSSWatcher.on("change", () => rebuildCSS("tailwind"));
52
- }
53
- console.log(`⌛ Waiting for file changes ...`);
54
- const watcher = watch(SOURCE_FOLDER);
55
- // The add watcher will add all the files initially - do not rebuild them
56
- let initialAdd = 0;
57
- let hasJSTS = false;
58
- watcher.on("add", (filename) => {
59
- start = performance.now();
60
- // Return if it was added by the build system itself
61
- if (/-bundle-\d+\.(j|t)sx?$/.test(filename)) {
62
- return;
63
- }
64
- filename = String.raw `${filename}`.replace(/\\/g, "/");
65
- if (filename.endsWith(".html") || filename.endsWith(".css")) {
66
- initialAdd++;
67
- }
68
- else if (hasJSTS === false && /\.(j|t)sx?$/.test(filename)) {
69
- hasJSTS = true;
70
- initialAdd++;
71
- }
72
- if (initialAdd <= expectedTasks)
73
- return;
74
- const [buildFilename, buildPathDir] = getBuildNames(filename);
75
- fs.mkdir(buildPathDir, { recursive: true }, (err) => {
76
- errorHandler(err);
77
- rebuild(filename);
78
- console.log(`⚡ added ${buildFilename}`);
79
- });
80
- });
81
- watcher.on("change", (filename) => {
82
- start = performance.now();
83
- // Return if it was changed by the build system itself
84
- if (/-bundle-\d+\.(j|t)sx?$/.test(filename)) {
85
- return;
86
- }
87
- filename = String.raw `${filename}`.replace(/\\/g, "/");
88
- rebuild(filename);
89
- const [buildFilename] = getBuildNames(filename);
90
- console.log(`⚡ modified ${buildFilename}`);
91
- });
92
- watcher.on("unlink", (filename) => {
93
- start = performance.now();
94
- // Return if it was deleted by the build system itself
95
- if (/-bundle-\d+\.(j|t)sx?$/.test(filename)) {
96
- return;
97
- }
98
- filename = String.raw `${filename}`.replace(/\\/g, "/");
99
- JSTSFiles.delete(filename);
100
- const [buildFilename, buildPathDir] = getBuildNames(filename);
101
- fs.rm(tsMaybeX2JS(buildFilename), (err) => {
102
- errorHandler(err);
103
- console.log(`⚡ deleted ${buildFilename}`);
104
- const length = fs.readdirSync(buildPathDir).length;
105
- if (!length)
106
- fs.rmdir(buildPathDir, errorHandler);
107
- });
108
- });
109
- }
110
- }
111
- });
112
- function rebuildCSS(config) {
113
- start = performance.now();
114
- console.log(`⚡ modified ${config}.config – CSS will rebuild now.`);
115
- const newConfig = createPostCSSConfig();
116
- plugins = newConfig.plugins;
117
- options = newConfig.options;
118
- CSSprocessor = postcss(plugins);
119
- glob(`${SOURCE_FOLDER}/**/*.css`, {}, (err, files) => {
120
- errorHandler(err);
121
- expectedTasks += files.length;
122
- for (const filename of files) {
123
- const [buildFilename, buildPathDir] = getBuildNames(filename);
124
- fs.mkdirSync(buildPathDir, { recursive: true });
125
- minifyCSS(filename, buildFilename);
126
- }
127
- });
128
- }
129
- // Basic configuration
130
- const SOURCE_FOLDER = "src";
131
- const BUILD_FOLDER = "build";
132
- const TEMPLATE_LITERAL_MINIFIER = /\n\s+/g;
133
- const CONNECTIONS = []; // HMR
134
- let htmlTasks = 0;
135
- let serverSentEvents;
136
- if (isHMR) {
137
- fastify = Fastify(isSecure
138
- ? {
139
- http2: true,
140
- https: {
141
- key: fs.readFileSync(path.join(process.cwd(), "localhost-key.pem")),
142
- cert: fs.readFileSync(path.join(process.cwd(), "localhost.pem")),
143
- },
144
- }
145
- : void 0);
146
- fastify.setNotFoundHandler((_req, reply) => {
147
- const file = fs.readFileSync(path.join(process.cwd(), BUILD_FOLDER, "/index.html"), {
148
- encoding: "utf-8",
149
- });
150
- reply.header("Content-Type", "text/html; charset=UTF-8");
151
- return reply.send(addHMRCode(file, "build/index.html"));
152
- });
153
- fastify.register(fastifyStatic, {
154
- root: path.join(process.cwd(), BUILD_FOLDER),
155
- });
156
- fastify.get("/events", (_req, reply) => {
157
- reply.raw.setHeader("Content-Type", "text/event-stream");
158
- reply.raw.setHeader("Cache-Control", "no-cache");
159
- !isSecure && reply.raw.setHeader("Connection", "keep-alive");
160
- CONNECTIONS.push(reply.raw);
161
- serverSentEvents = (data) => CONNECTIONS.forEach((rep) => {
162
- rep.write(`data: ${JSON.stringify(data)}\n\n`);
163
- });
164
- });
165
- }
166
- // THE BUNDLE CODE
167
- // Glob all files and transform the code
168
- glob(`${SOURCE_FOLDER}/**/*.html`, {}, (err, files) => {
169
- errorHandler(err);
170
- expectedTasks += files.length;
171
- htmlTasks += files.length;
172
- if (isHMR) {
173
- createHMRHandlers(files);
174
- fastify.listen(5000);
175
- console.log(`💻 Sever listening on port 5000.`);
176
- }
177
- });
178
- glob(`${SOURCE_FOLDER}/**/*.css`, {}, (err, files) => {
179
- errorHandler(err);
180
- expectedTasks += files.length;
181
- for (const filename of files) {
182
- const [buildFilename, buildPathDir] = getBuildNames(filename);
183
- fs.mkdirSync(buildPathDir, { recursive: true });
184
- minifyCSS(filename, buildFilename);
185
- }
186
- });
187
- const JSTSFiles = new Set();
188
- glob(`${SOURCE_FOLDER}/**/!(*.d).{ts,js,tsx,jsx}`, {}, (err, files) => {
189
- errorHandler(err);
190
- if (files.length) {
191
- expectedTasks += 1;
192
- }
193
- else {
194
- globHTML.emit("getReady");
195
- }
196
- files.forEach((file) => JSTSFiles.add(file));
197
- minifyTSJS().catch(errorHandler);
198
- });
199
- globHTML.on("getReady", () => {
200
- if (expectedTasks - htmlTasks === finishedTasks) {
201
- // After CSS and JS because critical needs file built css files and inline script might reference js files.
202
- glob(`${SOURCE_FOLDER}/**/*.html`, {}, async (err, files) => {
203
- errorHandler(err);
204
- await createGlobalJS(files);
205
- files.forEach((filename) => {
206
- const [buildFilename, buildPathDir] = getBuildNames(filename);
207
- fs.mkdirSync(buildPathDir, { recursive: true });
208
- minifyHTML(filename, buildFilename);
209
- });
210
- });
211
- }
212
- });
213
- function createGlobalJS(files) {
214
- const scriptFilenames = [];
215
- files.forEach((filename) => {
216
- const fileText = fs.readFileSync(filename, { encoding: "utf-8" });
217
- let DOM;
218
- if (fileText.includes("<!DOCTYPE html>") || fileText.includes("<html")) {
219
- DOM = parse(fileText);
220
- }
221
- else {
222
- DOM = parseFragment(fileText);
223
- }
224
- const scripts = findElements(DOM, (e) => getTagName(e) === "script");
225
- scripts.forEach((script, index) => {
226
- const scriptTextNode = script.childNodes[0];
227
- const isReferencedScript = script.attrs.find((a) => a.name === "src");
228
- //@ts-ignore
229
- const scriptContent = scriptTextNode?.value;
230
- if (!scriptContent || isReferencedScript)
231
- return;
232
- const jsFilename = filename.replace(".html", `-bundle-${index}.js`);
233
- scriptFilenames.push(jsFilename);
234
- fs.writeFileSync(jsFilename, scriptContent);
235
- });
236
- });
237
- scriptFilenames.forEach((file) => JSTSFiles.add(file));
238
- return minifyTSJS(true)
239
- .catch(console.error)
240
- .finally(() => scriptFilenames.forEach((file) => {
241
- JSTSFiles.delete(file);
242
- try {
243
- fs.rmSync(file);
244
- }
245
- catch { }
246
- }));
247
- }
248
- function minifyTSJS(isInline = false, file) {
249
- return esbuild
250
- .build({
251
- entryPoints: Array.from(JSTSFiles),
252
- charset: "utf8",
253
- format: "esm",
254
- incremental: isHMR,
255
- sourcemap: isHMR,
256
- splitting: true,
257
- define: {
258
- "process.env.NODE_ENV": isHMR ? '"development"' : '"production"',
259
- },
260
- loader: { ".js": "jsx", ".ts": "tsx" },
261
- bundle: true,
262
- minify: true,
263
- outdir: BUILD_FOLDER,
264
- outbase: SOURCE_FOLDER,
265
- })
266
- .then(() => {
267
- if (!isInline) {
268
- taskEmitter.emit("done");
269
- globHTML.emit("getReady");
270
- if (serverSentEvents && file) {
271
- const changedFile = tsMaybeX2JS(file);
272
- const [buildFilename] = getBuildNames(changedFile);
273
- const js = fs.readFileSync(buildFilename, { encoding: "utf8" });
274
- serverSentEvents({
275
- js,
276
- filename: buildFilename.split(`${BUILD_FOLDER}/`).pop(),
277
- });
278
- }
279
- }
280
- });
281
- }
282
- function minifyCSS(filename, buildFilename) {
283
- const fileText = fs.readFileSync(filename, { encoding: "utf-8" });
284
- return CSSprocessor.process(fileText, {
285
- ...options,
286
- from: filename,
287
- to: buildFilename,
288
- })
289
- .then((result) => {
290
- fs.writeFileSync(buildFilename, result.css);
291
- taskEmitter.emit("done");
292
- globHTML.emit("getReady");
293
- if (serverSentEvents) {
294
- serverSentEvents({
295
- css: result.css,
296
- filename: buildFilename.split(`${BUILD_FOLDER}/`).pop(),
297
- });
298
- }
299
- })
300
- .catch((err) => {
301
- console.error(err);
302
- });
303
- }
304
- async function minifyHTML(filename, buildFilename) {
305
- let fileText = fs.readFileSync(filename, { encoding: "utf-8" });
306
- let DOM;
307
- if (fileText.includes("<!DOCTYPE html>") || fileText.includes("<html")) {
308
- DOM = parse(fileText);
309
- }
310
- else {
311
- DOM = parseFragment(fileText);
312
- }
313
- // Minify Code
314
- const scripts = findElements(DOM, (e) => getTagName(e) === "script");
315
- scripts.forEach((script, index) => {
316
- const scriptTextNode = script.childNodes[0];
317
- const isReferencedScript = script.attrs.find((a) => a.name === "src");
318
- //@ts-ignore
319
- if (!scriptTextNode?.value || isReferencedScript)
320
- return;
321
- // Use bundled file and remove it from fs
322
- const bundledFilename = buildFilename.replace(".html", `-bundle-${index}.js`);
323
- try {
324
- const scriptContent = fs.readFileSync(bundledFilename, {
325
- encoding: "utf-8",
326
- });
327
- fs.rmSync(bundledFilename);
328
- // Replace src with bundled code
329
- //@ts-ignore
330
- scriptTextNode.value = scriptContent.replace(TEMPLATE_LITERAL_MINIFIER, " ");
331
- }
332
- catch { }
333
- });
334
- // Minify Inline Style
335
- const styles = findElements(DOM, (e) => getTagName(e) === "style");
336
- for (const style of styles) {
337
- const node = style.childNodes[0];
338
- //@ts-ignore
339
- const styleContent = node?.value;
340
- if (!styleContent)
341
- continue;
342
- const { css } = await CSSprocessor.process(styleContent, {
343
- ...options,
344
- from: undefined,
345
- });
346
- //@ts-ignore
347
- node.value = css;
348
- }
349
- fileText = serialize(DOM);
350
- // Minify HTML
351
- fileText = await minify(fileText, {
352
- collapseWhitespace: true,
353
- removeComments: true,
354
- });
355
- if (isCritical) {
356
- const buildFilenameArr = buildFilename.split("/");
357
- const fileWithBase = buildFilenameArr.pop();
358
- const buildDir = buildFilenameArr.join("/");
359
- // critical is generating the files on the fs
360
- return critical
361
- .generate({
362
- base: buildDir,
363
- html: fileText,
364
- target: fileWithBase,
365
- inline: !isCSP,
366
- extract: true,
367
- rebase: () => { },
368
- })
369
- .then(({ html }) => {
370
- taskEmitter.emit("done");
371
- if (serverSentEvents) {
372
- serverSentEvents({
373
- html: addHMRCode(html, buildFilename),
374
- filename: buildFilename,
375
- });
376
- }
377
- })
378
- .catch((err) => {
379
- console.error(err);
380
- });
381
- }
382
- else {
383
- fs.writeFileSync(buildFilename, fileText);
384
- taskEmitter.emit("done");
385
- if (serverSentEvents) {
386
- serverSentEvents({
387
- html: addHMRCode(fileText, buildFilename),
388
- filename: buildFilename,
389
- });
390
- }
391
- }
392
- }
393
- // Helper functions from here
394
- function createPostCSSConfig() {
395
- try {
396
- return postcssrc.sync({});
397
- }
398
- catch {
399
- return { plugins: [cssnano], options: {}, file: "" };
400
- }
401
- }
402
- function getBuildNames(filename) {
403
- const buildFilename = filename.replace(`${SOURCE_FOLDER}/`, `${BUILD_FOLDER}/`);
404
- const buildFilenameArr = buildFilename.split("/");
405
- buildFilenameArr.pop();
406
- const buildPathDir = buildFilenameArr.join("/");
407
- return [buildFilename, buildPathDir];
408
- }
409
- async function rebuild(filename) {
410
- const [buildFilename] = getBuildNames(filename);
411
- if (/\.(j|t)sx?$/.test(filename)) {
412
- JSTSFiles.add(filename);
413
- }
414
- else if (filename.endsWith(".css")) {
415
- await minifyCSS(filename, buildFilename);
416
- }
417
- glob(`${SOURCE_FOLDER}/**/*.html`, {}, async (err, files) => {
418
- errorHandler(err);
419
- await createGlobalJS(files);
420
- if (filename.endsWith(".html")) {
421
- minifyHTML(filename, buildFilename);
422
- }
423
- else if (/\.(j|t)sx?$/.test(filename) ||
424
- (filename.endsWith(".css") && isCritical)) {
425
- for (const htmlFilename of files) {
426
- const [htmlBuildFilename] = getBuildNames(htmlFilename);
427
- await minifyHTML(htmlFilename, htmlBuildFilename);
428
- }
429
- if (/\.(j|t)sx?$/.test(filename) && serverSentEvents) {
430
- const jsFile = tsMaybeX2JS(buildFilename);
431
- try {
432
- // Do not try to send empty files
433
- serverSentEvents({
434
- js: fs.readFileSync(jsFile, { encoding: "utf-8" }),
435
- filename: jsFile.split(`${BUILD_FOLDER}/`).pop(),
436
- });
437
- }
438
- catch { }
439
- }
440
- }
441
- });
442
- }
443
- const getHMRCode = (filename, id) => `import { render, html, setShouldSetReactivity, $$, setGlobalSchedule, setInsertDiffing } from "https://unpkg.com/hydro-js/dist/library.js";
444
-
445
- if (!window.eventsource${id}) {
446
- setGlobalSchedule(false);
447
- setShouldSetReactivity(false);
448
-
449
- window.eventsource${id} = new EventSource("/events");
450
- window.eventsource${id}.addEventListener("message", ({ data }) => {
451
- const dataObj = JSON.parse(data);
452
-
453
- if ("html" in dataObj && "${filename}" === dataObj.filename) {
454
- setInsertDiffing(true);
455
-
456
- let newHTML;
457
- let isBody;
458
-
459
- if (dataObj.html.startsWith('<!DOCTYPE html>') || dataObj.html.startsWith('<html')) {
460
- newHTML = html\`\${dataObj.html}\`;
461
- } else {
462
- newHTML = html\`<body>\${dataObj.html}</body>\`
463
- isBody = true
464
- }
465
-
466
- if (isBody) {
467
- const hmrID = "${id}";
468
- const hmrElems = Array.from(newHTML.childNodes);
469
- const hmrWheres = Array.from($$(\`[data-hmr="\${hmrID}"]\`))
470
- // Render new Elements in old Elements, also remove rest old Elements and add add new elements after the last old one
471
- hmrWheres.forEach((where, index) => {
472
- if (index < hmrElems.length) {
473
- render(hmrElems[index], where);
474
- } else {
475
- where.remove();
476
- }
477
- });
478
- for (let rest = hmrWheres.length; rest < hmrElems.length; rest++) {
479
- if (hmrWheres.length) {
480
- const template = document.createElement('template');
481
- hmrElems[hmrWheres.length - 1].after(template);
482
- render(hmrElems[rest], template);
483
- template.remove();
484
- } else {
485
- render(hmrElems[rest])
486
- }
487
- }
488
- } else {
489
- const oldElementCount = document.body.querySelectorAll('*').length;
490
- render(newHTML, document.documentElement);
491
- const newElementCount = document.body.querySelectorAll('*').length;
492
-
493
- // Looks like JS did not reload? Last resort - hard refresh
494
- if (newElementCount < 5 && Math.abs(newElementCount - oldElementCount) > 10) {
495
- location.reload()
496
- }
497
- }
498
- setInsertDiffing(false);
499
- if (dataObj.filename === 'build/index.html') {
500
- dispatchEvent(new Event("popstate"));
501
- }
502
- } else if ("css" in dataObj) {
503
- window.onceEveryXTime(100, window.updateCSS, [updateAttr]);
504
- } else if ("js" in dataObj) {
505
- window.onceEveryXTime(100, window.updateJS, [updateAttr]);
506
- }
507
-
508
- function updateAttr (attr, forceUpdate = false) {
509
- return (elem) => {
510
- const attrValue = elem[attr].replace(/\\?v=.*/, "");
511
- if (forceUpdate || attrValue.endsWith(dataObj.filename)) {
512
- elem[attr] = \`\${attrValue}?v=\${Math.random().toFixed(4)}\`;
513
- } else if (elem.localName === 'script' && !elem.src && new RegExp(\`["']\${dataObj.filename}["']\`).test(elem.textContent)) {
514
- elem.setAttribute('data-inline', String(Math.random().toFixed(4)).slice(2));
515
- }
516
- }
517
- };
518
- });
519
-
520
- if (!window.updateCSS) {
521
- window.updateCSS = function updateCSS(updateAttr) {
522
- $$('link').forEach(updateAttr("href"));
523
- window.fnToLastCalled.set(window.updateCSS, performance.now())
524
- }
525
- }
526
- if (!window.updateJS) {
527
- window.updateJS = function updateJS(updateAttr) {
528
- window.fnToLastCalled.set(window.updateJS, performance.now());
529
- const copy = html\`\${document.documentElement.outerHTML}\`;
530
- copy.querySelectorAll('script').forEach(updateAttr("src"));
531
- render(copy, document.documentElement);
532
- }
533
- }
534
- if (!window.fnToLastCalled) {
535
- window.fnToLastCalled = new Map();
536
- }
537
- if (!window.onceEveryXTime) {
538
- window.onceEveryXTime = function (time, fn, params) {
539
- if (!window.fnToLastCalled.has(fn) || performance.now() - window.fnToLastCalled.get(fn) > time) {
540
- fn(...params)
541
- }
542
- }
543
- }
544
- }`;
545
- function randomText() {
546
- return Math.random().toString(32).slice(2);
547
- }
548
- const htmlIdMap = new Map();
549
- function addHMRCode(html, filename) {
550
- if (!htmlIdMap.has(filename)) {
551
- htmlIdMap.set(filename, randomText());
552
- }
553
- const script = createScript({ type: "module" }, getHMRCode(filename, htmlIdMap.get(filename)));
554
- let ast;
555
- if (html.includes("<!DOCTYPE html>") || html.includes("<html")) {
556
- ast = parse(html);
557
- const headNode = findElement(ast, (e) => getTagName(e) === "head");
558
- appendChild(headNode, script);
559
- }
560
- else {
561
- ast = parseFragment(html);
562
- appendChild(ast, script);
563
- ast.childNodes.forEach((node) =>
564
- //@ts-ignore
565
- node.attrs?.push({ name: "data-hmr", value: htmlIdMap.get(filename) }));
566
- }
567
- // Burst CSS cache
568
- findElements(ast, (e) => getTagName(e) === "link").forEach((link) => {
569
- const href = link.attrs.find((attr) => attr.name === "href");
570
- const rel = link.attrs.find((attr) => attr.name === "rel");
571
- if (rel.value === "stylesheet") {
572
- href.value += `?v=${Math.random().toFixed(4)}`;
573
- }
574
- });
575
- return serialize(ast);
576
- }
577
- function createHMRHandlers(files) {
578
- files.forEach((filename) => {
579
- const newFilename = "/" + filename.replace(/src\//, "");
580
- const filePath = newFilename.split("/");
581
- const endName = filePath.pop();
582
- if (endName.endsWith("index.html")) {
583
- //@ts-ignore
584
- fastify.get(filePath.join("/") + "/", HMRHandler);
585
- }
586
- //@ts-ignore
587
- fastify.get(newFilename, HMRHandler);
588
- });
589
- }
590
- function HMRHandler(request, reply) {
591
- let filename = request.url;
592
- if (filename.endsWith("/")) {
593
- filename += "index.html";
594
- }
595
- filename = BUILD_FOLDER + filename;
596
- const file = fs.readFileSync(filename, {
597
- encoding: "utf-8",
598
- });
599
- reply.header("Content-Type", "text/html; charset=UTF-8");
600
- return reply.send(addHMRCode(file, filename));
601
- }
602
- function errorHandler(err) {
603
- if (err) {
604
- console.error(err);
605
- process.exit(1);
606
- }
607
- }
608
- function tsMaybeX2JS(filename) {
609
- return filename.replace(".ts", ".js").replace(".jsx", ".js");
610
- }
611
- }
612
- function createDefaultServer(BUILD_FOLDER = "build") {
613
- fastify = Fastify(isSecure
614
- ? {
615
- http2: true,
616
- https: {
617
- key: fs.readFileSync(path.join(process.cwd(), "localhost-key.pem")),
618
- cert: fs.readFileSync(path.join(process.cwd(), "localhost.pem")),
619
- },
620
- }
621
- : void 0);
622
- fastify.register(fastifyStatic, {
623
- root: path.join(process.cwd(), BUILD_FOLDER),
624
- });
625
- }