vite-react-ssg 0.1.1 → 0.1.2

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/node/cli.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
  const kolorist = require('kolorist');
4
4
  const yargs = require('yargs');
5
5
  const helpers = require('yargs/helpers');
6
- const dev = require('../shared/vite-react-ssg.8cbf43cc.cjs');
6
+ const dev = require('../shared/vite-react-ssg.b0fd1823.cjs');
7
7
  require('node:path');
8
8
  require('node:module');
9
9
  require('fs-extra');
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.5291bf32.mjs';
4
+ import { b as build, d as dev } from '../shared/vite-react-ssg.b83f6ed3.mjs';
5
5
  import 'node:path';
6
6
  import 'node:module';
7
7
  import 'fs-extra';
package/dist/node.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const dev = require('./shared/vite-react-ssg.8cbf43cc.cjs');
3
+ const dev = require('./shared/vite-react-ssg.b0fd1823.cjs');
4
4
  require('node:path');
5
5
  require('node:module');
6
6
  require('kolorist');
package/dist/node.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { b as build, d as dev } from './shared/vite-react-ssg.5291bf32.mjs';
1
+ export { b as build, d as dev } from './shared/vite-react-ssg.b83f6ed3.mjs';
2
2
  import 'node:path';
3
3
  import 'node:module';
4
4
  import 'kolorist';
@@ -934,7 +934,7 @@ async function resolveAlias(config, entry) {
934
934
  return result || node_path.join(config.root, entry);
935
935
  }
936
936
  const { version } = JSON.parse(
937
- node_fs.readFileSync(new URL("../../package.json", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('shared/vite-react-ssg.8cbf43cc.cjs', document.baseURI).href)))).toString()
937
+ node_fs.readFileSync(new URL("../../package.json", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('shared/vite-react-ssg.b0fd1823.cjs', document.baseURI).href)))).toString()
938
938
  );
939
939
 
940
940
  async function getCritters(outDir, options = {}) {
@@ -1019,9 +1019,8 @@ async function render(routes, request, styleCollector) {
1019
1019
  helmet.script.toString()
1020
1020
  ];
1021
1021
  const styleTag = styleCollector?.toString?.(appHTML) ?? "";
1022
- metaStrings.push(styleTag);
1023
1022
  const metaAttributes = metaStrings.filter(Boolean);
1024
- return { appHTML, htmlAttributes, bodyAttributes, metaAttributes };
1023
+ return { appHTML, htmlAttributes, bodyAttributes, metaAttributes, styleTag };
1025
1024
  }
1026
1025
 
1027
1026
  function renderPreloadLinks(document, modules, ssrManifest) {
@@ -1201,7 +1200,7 @@ async function build(ssgOptions = {}, viteConfig = {}) {
1201
1200
  const prefix = format === "esm" && process.platform === "win32" ? "file://" : "";
1202
1201
  const ext = format === "esm" ? ".mjs" : ".cjs";
1203
1202
  const serverEntry = node_path.join(prefix, ssgOut, node_path.parse(ssrEntry).name + ext);
1204
- const _require = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('shared/vite-react-ssg.8cbf43cc.cjs', document.baseURI).href)));
1203
+ const _require = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('shared/vite-react-ssg.b0fd1823.cjs', document.baseURI).href)));
1205
1204
  const { createRoot, includedRoutes: serverEntryIncludedRoutes } = format === "esm" ? await import(serverEntry) : _require(serverEntry);
1206
1205
  const includedRoutes = serverEntryIncludedRoutes || configIncludedRoutes;
1207
1206
  const { routes } = await createRoot(false);
@@ -1229,7 +1228,7 @@ async function build(ssgOptions = {}, viteConfig = {}) {
1229
1228
  url.hash = "";
1230
1229
  url.pathname = route;
1231
1230
  const request = new Request(url.href);
1232
- const { appHTML, bodyAttributes, htmlAttributes, metaAttributes } = await render([...routes2], request, styleCollector);
1231
+ const { appHTML, bodyAttributes, htmlAttributes, metaAttributes, styleTag } = await render([...routes2], request, styleCollector);
1233
1232
  await triggerOnSSRAppRendered?.(route, appHTML, appCtx);
1234
1233
  const renderedHTML = await renderHTML({
1235
1234
  rootContainerId,
@@ -1247,6 +1246,8 @@ async function build(ssgOptions = {}, viteConfig = {}) {
1247
1246
  let transformed = await onPageRendered?.(route, html, appCtx) || html;
1248
1247
  if (critters)
1249
1248
  transformed = await critters.process(transformed);
1249
+ if (styleTag)
1250
+ transformed = transformed.replace("<head>", `<head>${styleTag}`);
1250
1251
  const formatted = await formatHtml(transformed, formatting);
1251
1252
  const relativeRouteFile = `${(route.endsWith("/") ? `${route}index` : route).replace(/^\//g, "")}.html`;
1252
1253
  const filename = dirStyle === "nested" ? node_path.join(route.replace(/^\//g, ""), "index.html") : relativeRouteFile;
@@ -1426,7 +1427,8 @@ async function dev(ssgOptions = {}, viteConfig = {}) {
1426
1427
  const { routes, getStyleCollector } = appCtx;
1427
1428
  const transformedIndexHTML = await onBeforePageRender?.(url, indexHTML, appCtx) || indexHTML;
1428
1429
  const styleCollector = getStyleCollector ? await getStyleCollector() : null;
1429
- const { appHTML, bodyAttributes, htmlAttributes, metaAttributes } = await render([...routes], createFetchRequest(req), styleCollector);
1430
+ const { appHTML, bodyAttributes, htmlAttributes, metaAttributes, styleTag } = await render([...routes], createFetchRequest(req), styleCollector);
1431
+ metaAttributes.push(styleTag);
1430
1432
  const mod = await viteServer.moduleGraph.getModuleByUrl(entry);
1431
1433
  const assetsUrls = /* @__PURE__ */ new Set();
1432
1434
  const collectAssets = async (mod2) => {
@@ -1011,9 +1011,8 @@ async function render(routes, request, styleCollector) {
1011
1011
  helmet.script.toString()
1012
1012
  ];
1013
1013
  const styleTag = styleCollector?.toString?.(appHTML) ?? "";
1014
- metaStrings.push(styleTag);
1015
1014
  const metaAttributes = metaStrings.filter(Boolean);
1016
- return { appHTML, htmlAttributes, bodyAttributes, metaAttributes };
1015
+ return { appHTML, htmlAttributes, bodyAttributes, metaAttributes, styleTag };
1017
1016
  }
1018
1017
 
1019
1018
  function renderPreloadLinks(document, modules, ssrManifest) {
@@ -1221,7 +1220,7 @@ async function build(ssgOptions = {}, viteConfig = {}) {
1221
1220
  url.hash = "";
1222
1221
  url.pathname = route;
1223
1222
  const request = new Request(url.href);
1224
- const { appHTML, bodyAttributes, htmlAttributes, metaAttributes } = await render([...routes2], request, styleCollector);
1223
+ const { appHTML, bodyAttributes, htmlAttributes, metaAttributes, styleTag } = await render([...routes2], request, styleCollector);
1225
1224
  await triggerOnSSRAppRendered?.(route, appHTML, appCtx);
1226
1225
  const renderedHTML = await renderHTML({
1227
1226
  rootContainerId,
@@ -1239,6 +1238,8 @@ async function build(ssgOptions = {}, viteConfig = {}) {
1239
1238
  let transformed = await onPageRendered?.(route, html, appCtx) || html;
1240
1239
  if (critters)
1241
1240
  transformed = await critters.process(transformed);
1241
+ if (styleTag)
1242
+ transformed = transformed.replace("<head>", `<head>${styleTag}`);
1242
1243
  const formatted = await formatHtml(transformed, formatting);
1243
1244
  const relativeRouteFile = `${(route.endsWith("/") ? `${route}index` : route).replace(/^\//g, "")}.html`;
1244
1245
  const filename = dirStyle === "nested" ? join(route.replace(/^\//g, ""), "index.html") : relativeRouteFile;
@@ -1418,7 +1419,8 @@ async function dev(ssgOptions = {}, viteConfig = {}) {
1418
1419
  const { routes, getStyleCollector } = appCtx;
1419
1420
  const transformedIndexHTML = await onBeforePageRender?.(url, indexHTML, appCtx) || indexHTML;
1420
1421
  const styleCollector = getStyleCollector ? await getStyleCollector() : null;
1421
- const { appHTML, bodyAttributes, htmlAttributes, metaAttributes } = await render([...routes], createFetchRequest(req), styleCollector);
1422
+ const { appHTML, bodyAttributes, htmlAttributes, metaAttributes, styleTag } = await render([...routes], createFetchRequest(req), styleCollector);
1423
+ metaAttributes.push(styleTag);
1422
1424
  const mod = await viteServer.moduleGraph.getModuleByUrl(entry);
1423
1425
  const assetsUrls = /* @__PURE__ */ new Set();
1424
1426
  const collectAssets = async (mod2) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vite-react-ssg",
3
3
  "type": "module",
4
- "version": "0.1.1",
4
+ "version": "0.1.2",
5
5
  "packageManager": "pnpm@8.6.6",
6
6
  "description": "",
7
7
  "author": "Riri <Daydreamerriri@outlook.com>",