Setup for vite-based website

This commit is contained in:
Andrew Morris
2023-03-27 12:07:07 +11:00
parent 0f26aadd54
commit 168992f3b4
15 changed files with 6127 additions and 0 deletions

11
asdf/package.json Normal file
View File

@@ -0,0 +1,11 @@
{
"name": "website",
"version": "0.0.0",
"description": "ValueScript.org",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Andrew Morris",
"license": "MIT"
}

50
website2/.eslintrc.cjs Normal file
View File

@@ -0,0 +1,50 @@
// eslint-disable-next-line no-undef
module.exports = {
env: {
browser: true,
es2021: true,
},
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
],
overrides: [
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
plugins: [
'react',
'@typescript-eslint',
],
settings: {
react: {
version: 'detect',
},
},
rules: {
'indent': [
'error',
2,
],
'linebreak-style': [
'error',
'unix',
],
'quotes': [
'error',
'single',
],
'semi': [
'error',
'always',
],
'comma-dangle': ['error', 'always-multiline'],
'react/react-in-jsx-scope': 'off',
'quote-props': ['error', 'consistent-as-needed'],
},
};

23
website2/.gitignore vendored Normal file
View File

@@ -0,0 +1,23 @@
# 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/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

10
website2/.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,10 @@
{
"editor.rulers": [80],
"eslint.rules.customizations": [
{ "rule": "*", "severity": "warn" }
],
"editor.codeActionsOnSave": {
"source.fixAll": true
},
"editor.tabSize": 2
}

5840
website2/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

29
website2/package.json Normal file
View File

@@ -0,0 +1,29 @@
{
"name": "website",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/node": "^18.15.10",
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11",
"@typescript-eslint/eslint-plugin": "^5.56.0",
"@typescript-eslint/parser": "^5.56.0",
"@vitejs/plugin-react-swc": "^3.0.0",
"eslint": "^8.36.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-react": "^7.32.2",
"sass": "^1.60.0",
"typescript": "^4.9.3",
"vite": "^4.2.0"
}
}

15
website2/src/App.tsx Normal file
View File

@@ -0,0 +1,15 @@
import { useState } from 'react';
function App() {
const [count, setCount] = useState(0);
return (
<div className="App">
<button onClick={() => setCount((count) => count + 1)}>
count is {count}
</button>
</div>
);
}
export default App;

3
website2/src/app.html Normal file
View File

@@ -0,0 +1,3 @@
<script src="./main.tsx" type="module"></script>
<div id="root"></div>

23
website2/src/index.html Normal file
View File

@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name=viewport content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="./index.scss" />
</head>
<body>
<div id="main">
<div id="content">
<p id="heading">ValueScript</p>
<p>A dialect of TypeScript with value semantics.</p>
<div><a href="playground/">Try the playground</a></div>
<div><a href="https://github.com/voltrevo/ValueScript">Learn more</a></div>
</div>
</div>
<div style="display: none">
<a href="playground/index.html">Playground</a>
</div>
</body>
</html>

61
website2/src/index.scss Normal file
View File

@@ -0,0 +1,61 @@
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@100;300;400&display=swap');
body {
background-color: #160023;
color: white;
font-family: roboto, sans-serif;
font-size: 1.2em;
margin: 0;
overflow: hidden;
position: fixed;
}
h1, h3 {
text-align: center;
}
#main {
background-image: linear-gradient(125deg, rgb(6, 52, 29) 0%, rgb(7, 62, 69) 100%);
position: relative;
width: 100vw;
height: 100vh;
overflow-y: auto;
}
#heading {
font-size: calc(min(4em, 15vw));
margin: 0;
}
#content {
position: absolute;
left: 50vw;
vertical-align: middle;
top: 50vh;
width: 90vw;
transform: translate(-50%, -50%);
text-align: center;
font-size: 1.5em;
}
a, a:visited {
color: #ff5252;
text-decoration: none;
}
#content a {
border: 1.5px solid hsl(240, 81%, 24%);
border-radius: 0.4em;
background-color: hsl(228, 100%, 50%);
padding: 0.5em;
box-sizing: border-box;
display: inline-block;
margin-top: 1.5em;
color: white;
user-select: none;
transition: background-color 100ms;
}
#content a:hover {
background-color: hsl(228, 98%, 55%);
}

9
website2/src/main.tsx Normal file
View File

@@ -0,0 +1,9 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
<React.StrictMode>
<App />
</React.StrictMode>,
);

1
website2/src/vite-env.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
/// <reference types="vite/client" />

21
website2/tsconfig.json Normal file
View File

@@ -0,0 +1,21 @@
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}

View File

@@ -0,0 +1,9 @@
{
"compilerOptions": {
"composite": true,
"module": "ESNext",
"moduleResolution": "Node",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}

22
website2/vite.config.ts Normal file
View File

@@ -0,0 +1,22 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react-swc';
import { resolve } from 'path';
const src = resolve(__dirname, 'src');
const outDir = resolve(__dirname, 'dist');
// https://vitejs.dev/config/
export default defineConfig({
root: src,
plugins: [react()],
build: {
outDir,
emptyOutDir: true,
rollupOptions: {
input: {
main: resolve(src, 'index.html'),
app: resolve(src, 'app.html'),
},
},
},
});