Intermediate refactoring...
parent
471fad6d61
commit
5142d4c551
@ -0,0 +1,13 @@
|
||||
import Router from 'preact-router'
|
||||
|
||||
import { HomePage } from './pages/Home.jsx'
|
||||
import { LoginPage } from './pages/Login.jsx'
|
||||
import { ProblemPage } from './pages/Problem.jsx'
|
||||
|
||||
export const App = ({ path }) => (
|
||||
<Router>
|
||||
<HomePage path="/" />
|
||||
<LoginPage path="/login" />
|
||||
<ProblemPage path="/problem/:id" />
|
||||
</Router>
|
||||
)
|
@ -1,5 +1,4 @@
|
||||
import { useState } from 'preact/hooks'
|
||||
import { Link } from '../Router.jsx'
|
||||
|
||||
export const LoginPage = () => {
|
||||
const [username, setUsername] = useState('')
|
@ -1,28 +0,0 @@
|
||||
{
|
||||
"name": "@phc/problemi-frontend",
|
||||
"version": "0.0.1",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite --clearScreen false",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@preact/signals": "^1.1.2",
|
||||
"katex": "^0.16.3",
|
||||
"preact": "^10.11.2",
|
||||
"rehype-katex": "^6.0.2",
|
||||
"rehype-stringify": "^9.0.3",
|
||||
"remark-math": "^5.1.1",
|
||||
"remark-parse": "^10.0.1",
|
||||
"remark-rehype": "^10.1.0",
|
||||
"unified": "^10.1.2",
|
||||
"url-pattern": "^1.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@preact/preset-vite": "^2.4.0",
|
||||
"sass": "^1.55.0",
|
||||
"typescript": "^4.6.4",
|
||||
"vite": "^3.2.0"
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,18 +0,0 @@
|
||||
import { render } from 'preact'
|
||||
|
||||
import { Router } from './Router.jsx'
|
||||
|
||||
import { HomePage } from './pages/Home.jsx'
|
||||
import { LoginPage } from './pages/Login.jsx'
|
||||
import { ProblemPage } from './pages/Problem.jsx'
|
||||
|
||||
render(
|
||||
<Router
|
||||
pages={{
|
||||
'/': HomePage,
|
||||
'/login': LoginPage,
|
||||
'/problem/:id': ProblemPage,
|
||||
}}
|
||||
/>,
|
||||
document.body
|
||||
)
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,30 @@
|
||||
import path from 'path'
|
||||
import fs from 'fs/promises'
|
||||
|
||||
import { createServer as createViteServer } from 'vite'
|
||||
import express from 'express'
|
||||
|
||||
const CONSTANTS = {
|
||||
MODE_DEVELOPMENT: 'development',
|
||||
}
|
||||
|
||||
async function createDevelopmentServer(app) {
|
||||
const vite = await createViteServer({
|
||||
server: { middlewareMode: true },
|
||||
appType: 'custom',
|
||||
})
|
||||
|
||||
app.use(vite.middlewares)
|
||||
|
||||
app.use('*', async (req, res) => {
|
||||
// serve index.html
|
||||
const indexHtml = await fs.readFile(path.resolve('./client/index.html'), 'utf-8')
|
||||
const transformedIndexHtml = vite.transformIndexHtml(req.originalUrl, indexHtml)
|
||||
})
|
||||
}
|
||||
|
||||
function createProductionServer() {
|
||||
app.use('/', express.static('client/dist'))
|
||||
}
|
||||
|
||||
const app = express()
|
Loading…
Reference in New Issue