From 90ad177cc6fc137d4b7dbed9204387f15d778b52 Mon Sep 17 00:00:00 2001 From: Claas Date: Sat, 17 May 2025 10:30:05 +0200 Subject: [PATCH] Archive ssr project to try csr --- csr/.gitignore | 24 +++++++ csr/README.md | 28 ++++++++ csr/index.html | 13 ++++ csr/package.json | 19 +++++ csr/public/vite.svg | 1 + csr/src/App.css | 27 +++++++ csr/src/App.tsx | 35 +++++++++ csr/src/assets/solid.svg | 1 + csr/src/index.css | 68 ++++++++++++++++++ csr/src/index.tsx | 8 +++ csr/src/vite-env.d.ts | 1 + csr/tsconfig.app.json | 28 ++++++++ csr/tsconfig.json | 7 ++ csr/tsconfig.node.json | 25 +++++++ csr/vite.config.ts | 6 ++ README.md => ssr/README.md | 0 app.config.ts => ssr/app.config.ts | 0 biome.json => ssr/biome.json | 0 package.json => ssr/package.json | 0 pnpm-lock.yaml => ssr/pnpm-lock.yaml | 0 {public => ssr/public}/favicon.ico | Bin {src => ssr/src}/app.css | 0 {src => ssr/src}/app.tsx | 0 {src => ssr/src}/components/UrlForm.tsx | 0 {src => ssr/src}/entry-client.tsx | 0 {src => ssr/src}/entry-server.tsx | 0 {src => ssr/src}/global.d.ts | 0 .../src}/middleware/contentSecurityPolicy.ts | 0 {src => ssr/src}/routes/[...404].tsx | 0 {src => ssr/src}/routes/index.tsx | 0 tsconfig.json => ssr/tsconfig.json | 0 31 files changed, 291 insertions(+) create mode 100644 csr/.gitignore create mode 100644 csr/README.md create mode 100644 csr/index.html create mode 100644 csr/package.json create mode 100644 csr/public/vite.svg create mode 100644 csr/src/App.css create mode 100644 csr/src/App.tsx create mode 100644 csr/src/assets/solid.svg create mode 100644 csr/src/index.css create mode 100644 csr/src/index.tsx create mode 100644 csr/src/vite-env.d.ts create mode 100644 csr/tsconfig.app.json create mode 100644 csr/tsconfig.json create mode 100644 csr/tsconfig.node.json create mode 100644 csr/vite.config.ts rename README.md => ssr/README.md (100%) rename app.config.ts => ssr/app.config.ts (100%) rename biome.json => ssr/biome.json (100%) rename package.json => ssr/package.json (100%) rename pnpm-lock.yaml => ssr/pnpm-lock.yaml (100%) rename {public => ssr/public}/favicon.ico (100%) rename {src => ssr/src}/app.css (100%) rename {src => ssr/src}/app.tsx (100%) rename {src => ssr/src}/components/UrlForm.tsx (100%) rename {src => ssr/src}/entry-client.tsx (100%) rename {src => ssr/src}/entry-server.tsx (100%) rename {src => ssr/src}/global.d.ts (100%) rename {src => ssr/src}/middleware/contentSecurityPolicy.ts (100%) rename {src => ssr/src}/routes/[...404].tsx (100%) rename {src => ssr/src}/routes/index.tsx (100%) rename tsconfig.json => ssr/tsconfig.json (100%) diff --git a/csr/.gitignore b/csr/.gitignore new file mode 100644 index 0000000..a547bf3 --- /dev/null +++ b/csr/.gitignore @@ -0,0 +1,24 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/csr/README.md b/csr/README.md new file mode 100644 index 0000000..167c567 --- /dev/null +++ b/csr/README.md @@ -0,0 +1,28 @@ +## Usage + +```bash +$ npm install # or pnpm install or yarn install +``` + +### Learn more on the [Solid Website](https://solidjs.com) and come chat with us on our [Discord](https://discord.com/invite/solidjs) + +## Available Scripts + +In the project directory, you can run: + +### `npm run dev` + +Runs the app in the development mode.
+Open [http://localhost:5173](http://localhost:5173) to view it in the browser. + +### `npm run build` + +Builds the app for production to the `dist` folder.
+It correctly bundles Solid in production mode and optimizes the build for the best performance. + +The build is minified and the filenames include the hashes.
+Your app is ready to be deployed! + +## Deployment + +Learn more about deploying your application with the [documentations](https://vite.dev/guide/static-deploy.html) diff --git a/csr/index.html b/csr/index.html new file mode 100644 index 0000000..7021737 --- /dev/null +++ b/csr/index.html @@ -0,0 +1,13 @@ + + + + + + + Vite + Solid + TS + + +
+ + + diff --git a/csr/package.json b/csr/package.json new file mode 100644 index 0000000..b060704 --- /dev/null +++ b/csr/package.json @@ -0,0 +1,19 @@ +{ + "name": "shore", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "tsc -b && vite build", + "preview": "vite preview" + }, + "dependencies": { + "solid-js": "^1.9.5" + }, + "devDependencies": { + "typescript": "~5.8.3", + "vite": "^6.3.5", + "vite-plugin-solid": "^2.11.6" + } +} diff --git a/csr/public/vite.svg b/csr/public/vite.svg new file mode 100644 index 0000000..e7b8dfb --- /dev/null +++ b/csr/public/vite.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/csr/src/App.css b/csr/src/App.css new file mode 100644 index 0000000..613607d --- /dev/null +++ b/csr/src/App.css @@ -0,0 +1,27 @@ +#root { + max-width: 1280px; + margin: 0 auto; + padding: 2rem; + text-align: center; +} + +.logo { + height: 6em; + padding: 1.5em; + will-change: filter; + transition: filter 300ms; +} +.logo:hover { + filter: drop-shadow(0 0 2em #646cffaa); +} +.logo.solid:hover { + filter: drop-shadow(0 0 2em #61dafbaa); +} + +.card { + padding: 2em; +} + +.read-the-docs { + color: #888; +} diff --git a/csr/src/App.tsx b/csr/src/App.tsx new file mode 100644 index 0000000..bacc16a --- /dev/null +++ b/csr/src/App.tsx @@ -0,0 +1,35 @@ +import { createSignal } from 'solid-js' +import solidLogo from './assets/solid.svg' +import viteLogo from '/vite.svg' +import './App.css' + +function App() { + const [count, setCount] = createSignal(0) + + return ( + <> +
+ + + + + + +
+

Vite + Solid

+
+ +

+ Edit src/App.tsx and save to test HMR +

+
+

+ Click on the Vite and Solid logos to learn more +

+ + ) +} + +export default App diff --git a/csr/src/assets/solid.svg b/csr/src/assets/solid.svg new file mode 100644 index 0000000..025aa30 --- /dev/null +++ b/csr/src/assets/solid.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/csr/src/index.css b/csr/src/index.css new file mode 100644 index 0000000..08a3ac9 --- /dev/null +++ b/csr/src/index.css @@ -0,0 +1,68 @@ +:root { + font-family: system-ui, Avenir, Helvetica, Arial, sans-serif; + line-height: 1.5; + font-weight: 400; + + color-scheme: light dark; + color: rgba(255, 255, 255, 0.87); + background-color: #242424; + + font-synthesis: none; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +a { + font-weight: 500; + color: #646cff; + text-decoration: inherit; +} +a:hover { + color: #535bf2; +} + +body { + margin: 0; + display: flex; + place-items: center; + min-width: 320px; + min-height: 100vh; +} + +h1 { + font-size: 3.2em; + line-height: 1.1; +} + +button { + border-radius: 8px; + border: 1px solid transparent; + padding: 0.6em 1.2em; + font-size: 1em; + font-weight: 500; + font-family: inherit; + background-color: #1a1a1a; + cursor: pointer; + transition: border-color 0.25s; +} +button:hover { + border-color: #646cff; +} +button:focus, +button:focus-visible { + outline: 4px auto -webkit-focus-ring-color; +} + +@media (prefers-color-scheme: light) { + :root { + color: #213547; + background-color: #ffffff; + } + a:hover { + color: #747bff; + } + button { + background-color: #f9f9f9; + } +} diff --git a/csr/src/index.tsx b/csr/src/index.tsx new file mode 100644 index 0000000..f67cd20 --- /dev/null +++ b/csr/src/index.tsx @@ -0,0 +1,8 @@ +/* @refresh reload */ +import { render } from 'solid-js/web' +import './index.css' +import App from './App.tsx' + +const root = document.getElementById('root') + +render(() => , root!) diff --git a/csr/src/vite-env.d.ts b/csr/src/vite-env.d.ts new file mode 100644 index 0000000..11f02fe --- /dev/null +++ b/csr/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/csr/tsconfig.app.json b/csr/tsconfig.app.json new file mode 100644 index 0000000..9a0b51f --- /dev/null +++ b/csr/tsconfig.app.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", + "target": "ES2020", + "useDefineForClassFields": true, + "module": "ESNext", + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "moduleDetection": "force", + "noEmit": true, + "jsx": "preserve", + "jsxImportSource": "solid-js", + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "erasableSyntaxOnly": true, + "noFallthroughCasesInSwitch": true, + "noUncheckedSideEffectImports": true + }, + "include": ["src"] +} diff --git a/csr/tsconfig.json b/csr/tsconfig.json new file mode 100644 index 0000000..1ffef60 --- /dev/null +++ b/csr/tsconfig.json @@ -0,0 +1,7 @@ +{ + "files": [], + "references": [ + { "path": "./tsconfig.app.json" }, + { "path": "./tsconfig.node.json" } + ] +} diff --git a/csr/tsconfig.node.json b/csr/tsconfig.node.json new file mode 100644 index 0000000..9728af2 --- /dev/null +++ b/csr/tsconfig.node.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", + "target": "ES2022", + "lib": ["ES2023"], + "module": "ESNext", + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "moduleDetection": "force", + "noEmit": true, + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "erasableSyntaxOnly": true, + "noFallthroughCasesInSwitch": true, + "noUncheckedSideEffectImports": true + }, + "include": ["vite.config.ts"] +} diff --git a/csr/vite.config.ts b/csr/vite.config.ts new file mode 100644 index 0000000..4095d9b --- /dev/null +++ b/csr/vite.config.ts @@ -0,0 +1,6 @@ +import { defineConfig } from 'vite' +import solid from 'vite-plugin-solid' + +export default defineConfig({ + plugins: [solid()], +}) diff --git a/README.md b/ssr/README.md similarity index 100% rename from README.md rename to ssr/README.md diff --git a/app.config.ts b/ssr/app.config.ts similarity index 100% rename from app.config.ts rename to ssr/app.config.ts diff --git a/biome.json b/ssr/biome.json similarity index 100% rename from biome.json rename to ssr/biome.json diff --git a/package.json b/ssr/package.json similarity index 100% rename from package.json rename to ssr/package.json diff --git a/pnpm-lock.yaml b/ssr/pnpm-lock.yaml similarity index 100% rename from pnpm-lock.yaml rename to ssr/pnpm-lock.yaml diff --git a/public/favicon.ico b/ssr/public/favicon.ico similarity index 100% rename from public/favicon.ico rename to ssr/public/favicon.ico diff --git a/src/app.css b/ssr/src/app.css similarity index 100% rename from src/app.css rename to ssr/src/app.css diff --git a/src/app.tsx b/ssr/src/app.tsx similarity index 100% rename from src/app.tsx rename to ssr/src/app.tsx diff --git a/src/components/UrlForm.tsx b/ssr/src/components/UrlForm.tsx similarity index 100% rename from src/components/UrlForm.tsx rename to ssr/src/components/UrlForm.tsx diff --git a/src/entry-client.tsx b/ssr/src/entry-client.tsx similarity index 100% rename from src/entry-client.tsx rename to ssr/src/entry-client.tsx diff --git a/src/entry-server.tsx b/ssr/src/entry-server.tsx similarity index 100% rename from src/entry-server.tsx rename to ssr/src/entry-server.tsx diff --git a/src/global.d.ts b/ssr/src/global.d.ts similarity index 100% rename from src/global.d.ts rename to ssr/src/global.d.ts diff --git a/src/middleware/contentSecurityPolicy.ts b/ssr/src/middleware/contentSecurityPolicy.ts similarity index 100% rename from src/middleware/contentSecurityPolicy.ts rename to ssr/src/middleware/contentSecurityPolicy.ts diff --git a/src/routes/[...404].tsx b/ssr/src/routes/[...404].tsx similarity index 100% rename from src/routes/[...404].tsx rename to ssr/src/routes/[...404].tsx diff --git a/src/routes/index.tsx b/ssr/src/routes/index.tsx similarity index 100% rename from src/routes/index.tsx rename to ssr/src/routes/index.tsx diff --git a/tsconfig.json b/ssr/tsconfig.json similarity index 100% rename from tsconfig.json rename to ssr/tsconfig.json -- 2.51.2