vite-react-static
v0.1.2
Published
Static-site generation for React 18+ with Vite.
Downloads
178
Maintainers
Readme
Vite React Static (SSG)
Static-site generation for React 18+ with Vite.
Install
// package.json
{
"scripts": {
"dev": "vite",
- "build": "vite build"
+ "build": "vite-react-static build"
// OR if you want to use another vite config file
+ "build": "vite-react-static build -c another-vite.config.ts"
}
}// src/main.tsx
import { viteReactStatic } from 'vite-react-static'
const routes = [
{
path: '/',
element: <Layout />,
children: [
//...
]
},
]
// `export const createRoot` is required
export const createRoot = viteReactStatic({
routes
})Single Page SSG
// import { StrictMode } from 'react'
// import { createRoot } from 'react-dom/client'
import { viteReactStatic } from 'vite-react-static'
import './index.css'
import App from './App.tsx'
// createRoot(document.getElementById('root')!).render(
// <StrictMode>
// <App />
// </StrictMode>,
// )
export const createRoot = viteReactStatic(App)