setup build process
This commit is contained in:
+3
-6
@@ -4,12 +4,9 @@
|
|||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev:ssr": "ts-node --esm server.ts",
|
"build": "npm run build:client && npm run build:server",
|
||||||
"dev": "vite",
|
"build:client": "vite build --outDir dist/client",
|
||||||
"build": "tsc && vite build",
|
"build:server": "cross-env SSR=true vite build --outDir dist/server"
|
||||||
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
|
||||||
"preview": "vite preview",
|
|
||||||
"start": "tsc && vite build && serve -p 8099 -s ./dist"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/express": "^5.0.0",
|
"@types/express": "^5.0.0",
|
||||||
|
|||||||
@@ -20,8 +20,11 @@ export default function Header({
|
|||||||
"where else would you rather be..",
|
"where else would you rather be..",
|
||||||
"..than right here, right now?!"
|
"..than right here, right now?!"
|
||||||
]
|
]
|
||||||
const [ quote, setQuote ] = useState<string>(quoteArray[Math.floor(Math.random() * quoteArray.length)]);
|
const [ quote, setQuote ] = useState<string>(quoteArray[0]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setQuote(quoteArray[Math.floor(Math.random() * quoteArray.length)])
|
||||||
|
}, [])
|
||||||
const drawNewQuote = () => {
|
const drawNewQuote = () => {
|
||||||
const newQuote = quoteArray[Math.floor(Math.random() * quoteArray.length)]
|
const newQuote = quoteArray[Math.floor(Math.random() * quoteArray.length)]
|
||||||
|
|
||||||
|
|||||||
+9
-2
@@ -1,8 +1,15 @@
|
|||||||
import { defineConfig } from 'vite'
|
import { defineConfig } from 'vite'
|
||||||
import react from '@vitejs/plugin-react'
|
import react from '@vitejs/plugin-react'
|
||||||
|
|
||||||
// https://vitejs.dev/config/
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [react()],
|
plugins: [react()],
|
||||||
publicDir: "./src/public"
|
publicDir: './src/public',
|
||||||
|
build: {
|
||||||
|
copyPublicDir: !!process.env.SSR,
|
||||||
|
ssr: !!process.env.SSR,
|
||||||
|
outDir: process.env.SSR ? 'dist/server' : 'dist/client',
|
||||||
|
rollupOptions: {
|
||||||
|
input: process.env.SSR ? './server.ts' : './index.html'
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user