feat: Introduce SSG
This commit is contained in:
13 files changed
+157
-47
No files matched your search
@@ -1,11 +1,8 @@
|
||||
import { defineServiceConfig } from '@ermnvldmr/rsbuild-config/dev';
|
||||
import { defineServiceConfig, discoverEntries } from '@ermnvldmr/rsbuild-config/dev';
|
||||
|
||||
export default defineServiceConfig({
|
||||
source: {
|
||||
entry: {
|
||||
index: './src/app/index.tsx',
|
||||
error: './src/app/error.tsx',
|
||||
},
|
||||
entry: discoverEntries(import.meta.dirname, './src/app/**/*.tsx'),
|
||||
},
|
||||
html: {
|
||||
title: 'Static Content',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { createRoot } from 'react-dom/client';
|
||||
import { createRoot, hydrateRoot } from 'react-dom/client';
|
||||
import '../../static/global.css';
|
||||
|
||||
/**
|
||||
@@ -29,10 +29,16 @@ export function createPage(Component: React.ComponentType, options: PageOptions
|
||||
}
|
||||
|
||||
if (rootElement) {
|
||||
createRoot(rootElement).render(
|
||||
const node = (
|
||||
<React.StrictMode>
|
||||
<Component />
|
||||
</React.StrictMode>
|
||||
);
|
||||
|
||||
if (rootElement.hasChildNodes()) {
|
||||
hydrateRoot(rootElement, node);
|
||||
} else {
|
||||
createRoot(rootElement).render(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user