vite-react-ssg 0.8.5-beta.1 → 0.8.5

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/README.md CHANGED
@@ -510,6 +510,11 @@ interface ViteReactSSGOptions {
510
510
  * @default 'src/main.ts'
511
511
  */
512
512
  entry?: string
513
+ /**
514
+ * The path of the index.html file (relative to the project root).
515
+ * @default 'index.html'
516
+ */
517
+ htmlEntry?: string
513
518
  /**
514
519
  * Mock browser global variables (window, document, etc...) from SSG.
515
520
  *
@@ -1,6 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
- import { V as ViteReactSSGContext, a as ViteReactSSGClientOptions } from '../shared/vite-react-ssg.BrImbdZU.mjs';
3
- export { C as CrittersOptions, I as IndexRouteRecord, N as NonIndexRouteRecord, R as RouteRecord, c as RouterFutureConfig, d as RouterOptions, S as StyleCollector, b as ViteReactSSGOptions } from '../shared/vite-react-ssg.BrImbdZU.mjs';
2
+ import { V as ViteReactSSGContext, a as ViteReactSSGClientOptions } from '../shared/vite-react-ssg.D2OE2Bw1.mjs';
3
+ export { C as CrittersOptions, I as IndexRouteRecord, N as NonIndexRouteRecord, R as RouteRecord, c as RouterFutureConfig, d as RouterOptions, S as StyleCollector, b as ViteReactSSGOptions } from '../shared/vite-react-ssg.D2OE2Bw1.mjs';
4
4
  export { C as ClientOnly, H as Head } from '../shared/vite-react-ssg.-NlgsPvg.mjs';
5
5
  import 'beasties';
6
6
  import 'react-router-dom';
@@ -1,6 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
- import { V as ViteReactSSGContext, a as ViteReactSSGClientOptions } from '../shared/vite-react-ssg.BrImbdZU.js';
3
- export { C as CrittersOptions, I as IndexRouteRecord, N as NonIndexRouteRecord, R as RouteRecord, c as RouterFutureConfig, d as RouterOptions, S as StyleCollector, b as ViteReactSSGOptions } from '../shared/vite-react-ssg.BrImbdZU.js';
2
+ import { V as ViteReactSSGContext, a as ViteReactSSGClientOptions } from '../shared/vite-react-ssg.D2OE2Bw1.js';
3
+ export { C as CrittersOptions, I as IndexRouteRecord, N as NonIndexRouteRecord, R as RouteRecord, c as RouterFutureConfig, d as RouterOptions, S as StyleCollector, b as ViteReactSSGOptions } from '../shared/vite-react-ssg.D2OE2Bw1.js';
4
4
  export { C as ClientOnly, H as Head } from '../shared/vite-react-ssg.-NlgsPvg.js';
5
5
  import 'beasties';
6
6
  import 'react-router-dom';
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { V as ViteReactSSGContext, d as RouterOptions, a as ViteReactSSGClientOptions } from './shared/vite-react-ssg.BrImbdZU.mjs';
2
- export { C as CrittersOptions, I as IndexRouteRecord, N as NonIndexRouteRecord, R as RouteRecord, c as RouterFutureConfig, S as StyleCollector, b as ViteReactSSGOptions } from './shared/vite-react-ssg.BrImbdZU.mjs';
1
+ import { V as ViteReactSSGContext, d as RouterOptions, a as ViteReactSSGClientOptions } from './shared/vite-react-ssg.D2OE2Bw1.mjs';
2
+ export { C as CrittersOptions, I as IndexRouteRecord, N as NonIndexRouteRecord, R as RouteRecord, c as RouterFutureConfig, S as StyleCollector, b as ViteReactSSGOptions } from './shared/vite-react-ssg.D2OE2Bw1.mjs';
3
3
  export { C as ClientOnly, H as Head } from './shared/vite-react-ssg.-NlgsPvg.mjs';
4
4
  import { LinkProps, NavLinkProps } from 'react-router-dom';
5
5
  import React from 'react';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { V as ViteReactSSGContext, d as RouterOptions, a as ViteReactSSGClientOptions } from './shared/vite-react-ssg.BrImbdZU.js';
2
- export { C as CrittersOptions, I as IndexRouteRecord, N as NonIndexRouteRecord, R as RouteRecord, c as RouterFutureConfig, S as StyleCollector, b as ViteReactSSGOptions } from './shared/vite-react-ssg.BrImbdZU.js';
1
+ import { V as ViteReactSSGContext, d as RouterOptions, a as ViteReactSSGClientOptions } from './shared/vite-react-ssg.D2OE2Bw1.js';
2
+ export { C as CrittersOptions, I as IndexRouteRecord, N as NonIndexRouteRecord, R as RouteRecord, c as RouterFutureConfig, S as StyleCollector, b as ViteReactSSGOptions } from './shared/vite-react-ssg.D2OE2Bw1.js';
3
3
  export { C as ClientOnly, H as Head } from './shared/vite-react-ssg.-NlgsPvg.js';
4
4
  import { LinkProps, NavLinkProps } from 'react-router-dom';
5
5
  import React from 'react';
package/dist/node/cli.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { gray, bold, red, reset, underline } from 'kolorist';
2
2
  import yargs from 'yargs';
3
3
  import { hideBin } from 'yargs/helpers';
4
- import { b as build, d as dev } from '../shared/vite-react-ssg.2P3UhU88.mjs';
4
+ import { b as build, d as dev } from '../shared/vite-react-ssg.EDckwhJo.mjs';
5
5
  import { Headers, Request, Response, fetch, FormData } from '@remix-run/web-fetch';
6
6
  import 'node:module';
7
7
  import 'node:path';
package/dist/node.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { InlineConfig } from 'vite';
2
- import { b as ViteReactSSGOptions } from './shared/vite-react-ssg.BrImbdZU.mjs';
2
+ import { b as ViteReactSSGOptions } from './shared/vite-react-ssg.D2OE2Bw1.mjs';
3
3
  import 'beasties';
4
4
  import 'react';
5
5
  import 'react-router-dom';
package/dist/node.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { InlineConfig } from 'vite';
2
- import { b as ViteReactSSGOptions } from './shared/vite-react-ssg.BrImbdZU.js';
2
+ import { b as ViteReactSSGOptions } from './shared/vite-react-ssg.D2OE2Bw1.js';
3
3
  import 'beasties';
4
4
  import 'react';
5
5
  import 'react-router-dom';
package/dist/node.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { b as build, d as dev } from './shared/vite-react-ssg.2P3UhU88.mjs';
1
+ export { b as build, d as dev } from './shared/vite-react-ssg.EDckwhJo.mjs';
2
2
  import 'node:module';
3
3
  import 'node:path';
4
4
  import 'fs-extra';
@@ -41,6 +41,11 @@ interface ViteReactSSGOptions<Context = ViteReactSSGContext> {
41
41
  * @default 'src/main.ts'
42
42
  */
43
43
  entry?: string;
44
+ /**
45
+ * The path of the index.html file (relative to the project root).
46
+ * @default 'index.html'
47
+ */
48
+ htmlEntry?: string;
44
49
  /**
45
50
  * Mock browser global variables (window, document, etc...) from SSG.
46
51
  *
@@ -41,6 +41,11 @@ interface ViteReactSSGOptions<Context = ViteReactSSGContext> {
41
41
  * @default 'src/main.ts'
42
42
  */
43
43
  entry?: string;
44
+ /**
45
+ * The path of the index.html file (relative to the project root).
46
+ * @default 'index.html'
47
+ */
48
+ htmlEntry?: string;
44
49
  /**
45
50
  * Mock browser global variables (window, document, etc...) from SSG.
46
51
  *
@@ -152,9 +152,9 @@ async function renderHTML({
152
152
  throw new Error(`Could not find a tag with id="${rootContainerId}" to replace it with server-side rendered HTML`);
153
153
  return renderedOutput;
154
154
  }
155
- async function detectEntry(root) {
155
+ async function detectEntry(root, htmlEntry = "index.html") {
156
156
  const scriptSrcReg = /<script(?:.*?)src=["'](.+?)["'](?!<)(?:.*)\>(?:[\n\r\s]*?)(?:<\/script>)/gim;
157
- const html = await fs.readFile(join(root, "index.html"), "utf-8");
157
+ const html = await fs.readFile(join(root, htmlEntry), "utf-8");
158
158
  const scripts = [...html.matchAll(scriptSrcReg)];
159
159
  const [, entry] = scripts.find((matchResult) => {
160
160
  const [script] = matchResult;
@@ -357,7 +357,7 @@ class WritableAsPromise extends Writable {
357
357
  }
358
358
  }
359
359
 
360
- const version = "0.8.5-beta.1";
360
+ const version = "0.8.5";
361
361
 
362
362
  function buildLog(text, count) {
363
363
  console.log(`
@@ -710,7 +710,8 @@ async function build(ssgOptions = {}, viteConfig = {}) {
710
710
  const {
711
711
  script = "sync",
712
712
  mock = false,
713
- entry = await detectEntry(root),
713
+ htmlEntry = "index.html",
714
+ entry = await detectEntry(root, htmlEntry),
714
715
  formatting = "none",
715
716
  includedRoutes: configIncludedRoutes = DefaultIncludedRoutes,
716
717
  onBeforePageRender,
@@ -739,7 +740,7 @@ async function build(ssgOptions = {}, viteConfig = {}) {
739
740
  ssrManifest: true,
740
741
  rollupOptions: {
741
742
  input: {
742
- app: join(root, "./index.html")
743
+ app: join(root, htmlEntry || "./index.html")
743
744
  },
744
745
  // @ts-expect-error rollup type
745
746
  onLog(level, log, handler) {
@@ -804,7 +805,8 @@ async function build(ssgOptions = {}, viteConfig = {}) {
804
805
  console.log(`${gray("[vite-react-ssg]")} ${blue("Critical CSS generation enabled via `beasties`")}`);
805
806
  const ssrManifest = JSON.parse(await fs.readFile(join(out, ...dotVitedir, "ssr-manifest.json"), "utf-8"));
806
807
  const manifest = JSON.parse(await fs.readFile(join(out, ...dotVitedir, "manifest.json"), "utf-8"));
807
- let indexHTML = await fs.readFile(join(out, "index.html"), "utf-8");
808
+ let indexHTML = await fs.readFile(join(out, htmlEntry), "utf-8");
809
+ fs.rmSync(join(out, htmlEntry));
808
810
  indexHTML = rewriteScripts(indexHTML, script);
809
811
  const queue = new PQueue({ concurrency });
810
812
  const crittersQueue = new PQueue({ concurrency: 1 });
@@ -983,14 +985,15 @@ async function dev(ssgOptions = {}, viteConfig = {}, customOptions) {
983
985
  const cwd = process.cwd();
984
986
  const root = config.root || cwd;
985
987
  const {
986
- entry = await detectEntry(root),
988
+ htmlEntry = "index.html",
989
+ entry = await detectEntry(root, htmlEntry),
987
990
  onBeforePageRender,
988
991
  onPageRendered,
989
992
  rootContainerId = "root",
990
993
  mock = false
991
994
  } = Object.assign({}, config.ssgOptions || {}, ssgOptions);
992
995
  const ssrEntry = await resolveAlias(config, entry);
993
- const template = await fs.readFile(join(root, "index.html"), "utf-8");
996
+ const template = await fs.readFile(join(root, htmlEntry), "utf-8");
994
997
  let viteServer;
995
998
  globalThis.__ssr_start_time = performance.now();
996
999
  createServer$1().catch((err) => {
@@ -1,6 +1,6 @@
1
1
  import { AnyRouter } from '@tanstack/react-router';
2
- import { V as ViteReactSSGContext$1, a as ViteReactSSGClientOptions } from './shared/vite-react-ssg.BrImbdZU.mjs';
3
- export { C as CrittersOptions, I as IndexRouteRecord, N as NonIndexRouteRecord, R as RouteRecord, c as RouterFutureConfig, S as StyleCollector, b as ViteReactSSGOptions } from './shared/vite-react-ssg.BrImbdZU.mjs';
2
+ import { V as ViteReactSSGContext$1, a as ViteReactSSGClientOptions } from './shared/vite-react-ssg.D2OE2Bw1.mjs';
3
+ export { C as CrittersOptions, I as IndexRouteRecord, N as NonIndexRouteRecord, R as RouteRecord, c as RouterFutureConfig, S as StyleCollector, b as ViteReactSSGOptions } from './shared/vite-react-ssg.D2OE2Bw1.mjs';
4
4
  export { C as ClientOnly, H as Head } from './shared/vite-react-ssg.-NlgsPvg.mjs';
5
5
  import 'beasties';
6
6
  import 'react';
@@ -1,6 +1,6 @@
1
1
  import { AnyRouter } from '@tanstack/react-router';
2
- import { V as ViteReactSSGContext$1, a as ViteReactSSGClientOptions } from './shared/vite-react-ssg.BrImbdZU.js';
3
- export { C as CrittersOptions, I as IndexRouteRecord, N as NonIndexRouteRecord, R as RouteRecord, c as RouterFutureConfig, S as StyleCollector, b as ViteReactSSGOptions } from './shared/vite-react-ssg.BrImbdZU.js';
2
+ import { V as ViteReactSSGContext$1, a as ViteReactSSGClientOptions } from './shared/vite-react-ssg.D2OE2Bw1.js';
3
+ export { C as CrittersOptions, I as IndexRouteRecord, N as NonIndexRouteRecord, R as RouteRecord, c as RouterFutureConfig, S as StyleCollector, b as ViteReactSSGOptions } from './shared/vite-react-ssg.D2OE2Bw1.js';
4
4
  export { C as ClientOnly, H as Head } from './shared/vite-react-ssg.-NlgsPvg.js';
5
5
  import 'beasties';
6
6
  import 'react';
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "vite-react-ssg",
3
3
  "type": "module",
4
- "version": "0.8.5-beta.1",
5
- "packageManager": "pnpm@10.4.1",
4
+ "version": "0.8.5",
5
+ "packageManager": "pnpm@10.5.0",
6
6
  "description": "Static-site generation for React on Vite.",
7
7
  "author": "Riri <Daydreamerriri@outlook.com>",
8
8
  "license": "MIT",