vite-react-ssg 0.8.5-beta.1 → 0.8.6
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 +6 -0
- package/dist/client/single-page.d.mts +2 -2
- package/dist/client/single-page.d.ts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/node/cli.mjs +1 -1
- package/dist/node.d.mts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.mjs +1 -1
- package/dist/shared/{vite-react-ssg.BrImbdZU.d.mts → vite-react-ssg.D2OE2Bw1.d.mts} +5 -0
- package/dist/shared/{vite-react-ssg.BrImbdZU.d.ts → vite-react-ssg.D2OE2Bw1.d.ts} +5 -0
- package/dist/shared/{vite-react-ssg.2P3UhU88.mjs → vite-react-ssg._Fe7_xAQ.mjs} +11 -8
- package/dist/tanstack.d.mts +2 -2
- package/dist/tanstack.d.ts +2 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -10,6 +10,7 @@ and [`wouter`](https://github.com/molefrog/wouter) is in progress!**
|
|
|
10
10
|
Support for the [`@tanstack/router`](https://tanstack.com/router/latest/docs/framework/react/overview) router is still experimental, and `pathname.lazy.tsx routes` are not yet supported.
|
|
11
11
|
For usage examples, see: [`main`/examples/tanstack/src/main.tsx](https://github.com/Daydreamer-riri/vite-react-ssg/blob/main/examples/tanstack/src/main.tsx)
|
|
12
12
|
|
|
13
|
+
[](https://github.com/vitejs/awesome-vite)
|
|
13
14
|
[](https://www.npmjs.com/package/vite-react-ssg)
|
|
14
15
|
|
|
15
16
|
## Table of contents
|
|
@@ -510,6 +511,11 @@ interface ViteReactSSGOptions {
|
|
|
510
511
|
* @default 'src/main.ts'
|
|
511
512
|
*/
|
|
512
513
|
entry?: string
|
|
514
|
+
/**
|
|
515
|
+
* The path of the index.html file (relative to the project root).
|
|
516
|
+
* @default 'index.html'
|
|
517
|
+
*/
|
|
518
|
+
htmlEntry?: string
|
|
513
519
|
/**
|
|
514
520
|
* Mock browser global variables (window, document, etc...) from SSG.
|
|
515
521
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { V as ViteReactSSGContext, a as ViteReactSSGClientOptions } from '../shared/vite-react-ssg.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
4
|
+
import { b as build, d as dev } from '../shared/vite-react-ssg._Fe7_xAQ.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.
|
|
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
package/dist/node.mjs
CHANGED
|
@@ -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,
|
|
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.
|
|
360
|
+
const version = "0.8.6";
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
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,
|
|
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) => {
|
package/dist/tanstack.d.mts
CHANGED
|
@@ -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.
|
|
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.
|
|
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';
|
package/dist/tanstack.d.ts
CHANGED
|
@@ -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.
|
|
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.
|
|
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
|
-
"packageManager": "pnpm@10.
|
|
4
|
+
"version": "0.8.6",
|
|
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",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"react-dom": "^17.0.2 || ^18.0.0 || ^19.0.0",
|
|
84
84
|
"react-router-dom": "^6.14.1",
|
|
85
85
|
"styled-components": "^6.0.0",
|
|
86
|
-
"vite": "^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0"
|
|
86
|
+
"vite": "^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0"
|
|
87
87
|
},
|
|
88
88
|
"peerDependenciesMeta": {
|
|
89
89
|
"@tanstack/react-router": {
|