diff options
author | Ilion Beyst <ilion.beyst@gmail.com> | 2021-12-30 14:15:40 +0100 |
---|---|---|
committer | Ilion Beyst <ilion.beyst@gmail.com> | 2021-12-30 14:15:40 +0100 |
commit | 522f4270e83a85564ecc977aa470fcf8560547e2 (patch) | |
tree | 0dc688bde37aecd470a259bccc89f8bf3d24e710 /web | |
parent | 3edf5d60f54bfd0cd2c818e5fb1ca133e324325d (diff) | |
download | planetwars.dev-522f4270e83a85564ecc977aa470fcf8560547e2.tar.xz planetwars.dev-522f4270e83a85564ecc977aa470fcf8560547e2.zip |
init SvelteKit frontend
Diffstat (limited to 'web')
-rw-r--r-- | web/pw-server/.eslintrc.cjs | 20 | ||||
-rw-r--r-- | web/pw-server/.gitignore | 9 | ||||
-rw-r--r-- | web/pw-server/.npmrc | 1 | ||||
-rw-r--r-- | web/pw-server/.prettierrc | 6 | ||||
-rw-r--r-- | web/pw-server/README.md | 38 | ||||
-rw-r--r-- | web/pw-server/package.json | 37 | ||||
-rw-r--r-- | web/pw-server/src/app.html | 13 | ||||
-rw-r--r-- | web/pw-server/src/global.d.ts | 1 | ||||
-rw-r--r-- | web/pw-server/src/routes/index.svelte | 2 | ||||
-rw-r--r-- | web/pw-server/static/favicon.ico | bin | 0 -> 3985 bytes | |||
-rw-r--r-- | web/pw-server/svelte.config.js | 49 | ||||
-rw-r--r-- | web/pw-server/tsconfig.json | 31 |
12 files changed, 207 insertions, 0 deletions
diff --git a/web/pw-server/.eslintrc.cjs b/web/pw-server/.eslintrc.cjs new file mode 100644 index 0000000..3ccf435 --- /dev/null +++ b/web/pw-server/.eslintrc.cjs @@ -0,0 +1,20 @@ +module.exports = { + root: true, + parser: '@typescript-eslint/parser', + extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'], + plugins: ['svelte3', '@typescript-eslint'], + ignorePatterns: ['*.cjs'], + overrides: [{ files: ['*.svelte'], processor: 'svelte3/svelte3' }], + settings: { + 'svelte3/typescript': () => require('typescript') + }, + parserOptions: { + sourceType: 'module', + ecmaVersion: 2020 + }, + env: { + browser: true, + es2017: true, + node: true + } +}; diff --git a/web/pw-server/.gitignore b/web/pw-server/.gitignore new file mode 100644 index 0000000..dc61a8d --- /dev/null +++ b/web/pw-server/.gitignore @@ -0,0 +1,9 @@ +.DS_Store +node_modules +/build +/.svelte-kit +/package +.env +.env.* +!.env.example +package-lock.json
\ No newline at end of file diff --git a/web/pw-server/.npmrc b/web/pw-server/.npmrc new file mode 100644 index 0000000..b6f27f1 --- /dev/null +++ b/web/pw-server/.npmrc @@ -0,0 +1 @@ +engine-strict=true diff --git a/web/pw-server/.prettierrc b/web/pw-server/.prettierrc new file mode 100644 index 0000000..ff2677e --- /dev/null +++ b/web/pw-server/.prettierrc @@ -0,0 +1,6 @@ +{ + "useTabs": true, + "singleQuote": true, + "trailingComma": "none", + "printWidth": 100 +} diff --git a/web/pw-server/README.md b/web/pw-server/README.md new file mode 100644 index 0000000..82510ca --- /dev/null +++ b/web/pw-server/README.md @@ -0,0 +1,38 @@ +# create-svelte + +Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte); + +## Creating a project + +If you're seeing this, you've probably already done this step. Congrats! + +```bash +# create a new project in the current directory +npm init svelte@next + +# create a new project in my-app +npm init svelte@next my-app +``` + +> Note: the `@next` is temporary + +## Developing + +Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server: + +```bash +npm run dev + +# or start the server and open the app in a new browser tab +npm run dev -- --open +``` + +## Building + +Before creating a production version of your app, install an [adapter](https://kit.svelte.dev/docs#adapters) for your target environment. Then: + +```bash +npm run build +``` + +> You can preview the built app with `npm run preview`, regardless of whether you installed an adapter. This should _not_ be used to serve your app in production. diff --git a/web/pw-server/package.json b/web/pw-server/package.json new file mode 100644 index 0000000..29d59f6 --- /dev/null +++ b/web/pw-server/package.json @@ -0,0 +1,37 @@ +{ + "name": "pw-server", + "version": "0.0.1", + "scripts": { + "dev": "svelte-kit dev", + "build": "svelte-kit build", + "package": "svelte-kit package", + "preview": "svelte-kit preview", + "check": "svelte-check --tsconfig ./tsconfig.json", + "check:watch": "svelte-check --tsconfig ./tsconfig.json --watch", + "lint": "prettier --ignore-path .gitignore --check --plugin-search-dir=. . && eslint --ignore-path .gitignore .", + "format": "prettier --ignore-path .gitignore --write --plugin-search-dir=. ." + }, + "devDependencies": { + "@sveltejs/adapter-auto": "next", + "@sveltejs/kit": "next", + "@typescript-eslint/eslint-plugin": "^4.31.1", + "@typescript-eslint/parser": "^4.31.1", + "@originjs/vite-plugin-commonjs": "^1.0.1", + "@sveltejs/vite-plugin-svelte": "^1.0.0-next.30", + "vite-plugin-wasm-pack": "^0.1.9", + "eslint": "^7.32.0", + "eslint-config-prettier": "^8.3.0", + "eslint-plugin-svelte3": "^3.2.1", + "prettier": "^2.4.1", + "prettier-plugin-svelte": "^2.4.0", + "svelte": "^3.44.0", + "svelte-check": "^2.2.6", + "svelte-preprocess": "^4.9.4", + "tslib": "^2.3.1", + "typescript": "^4.4.3" + }, + "dependencies": { + "moment": "^2.29.1" + }, + "type": "module" +}
\ No newline at end of file diff --git a/web/pw-server/src/app.html b/web/pw-server/src/app.html new file mode 100644 index 0000000..9c8080f --- /dev/null +++ b/web/pw-server/src/app.html @@ -0,0 +1,13 @@ +<!DOCTYPE html> +<html lang="en"> + <head> + <meta charset="utf-8" /> + <meta name="description" content="" /> + <link rel="icon" href="/favicon.ico" /> + <meta name="viewport" content="width=device-width, initial-scale=1" /> + %svelte.head% + </head> + <body> + <div id="svelte">%svelte.body%</div> + </body> +</html> diff --git a/web/pw-server/src/global.d.ts b/web/pw-server/src/global.d.ts new file mode 100644 index 0000000..63908c6 --- /dev/null +++ b/web/pw-server/src/global.d.ts @@ -0,0 +1 @@ +/// <reference types="@sveltejs/kit" /> diff --git a/web/pw-server/src/routes/index.svelte b/web/pw-server/src/routes/index.svelte new file mode 100644 index 0000000..5982b0a --- /dev/null +++ b/web/pw-server/src/routes/index.svelte @@ -0,0 +1,2 @@ +<h1>Welcome to SvelteKit</h1> +<p>Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation</p> diff --git a/web/pw-server/static/favicon.ico b/web/pw-server/static/favicon.ico Binary files differnew file mode 100644 index 0000000..628e6ed --- /dev/null +++ b/web/pw-server/static/favicon.ico diff --git a/web/pw-server/svelte.config.js b/web/pw-server/svelte.config.js new file mode 100644 index 0000000..14e6a05 --- /dev/null +++ b/web/pw-server/svelte.config.js @@ -0,0 +1,49 @@ +import adapter from '@sveltejs/adapter-auto'; +import preprocess from 'svelte-preprocess'; +// import { svelte } from '@sveltejs/vite-plugin-svelte' +import { viteCommonjs } from '@originjs/vite-plugin-commonjs' +import wasmPack from 'vite-plugin-wasm-pack'; + + +/** @type {import('@sveltejs/kit').Config} */ +const config = { + // Consult https://github.com/sveltejs/svelte-preprocess + // for more information about preprocessors + preprocess: preprocess(), + + kit: { + adapter: adapter(), + + // hydrate the <div id="svelte"> element in src/app.html + target: '#svelte', + ssr: false, + vite: { + plugins: [ + // svelte(), + // wasmPack([], ["planetwars-rs"]), + viteCommonjs({ + transformMixedEsModules: true, + }), + ], + build: { + commonjsOptions: { + transformMixedEsModules: true, + }, + }, + server: { + proxy: { + "/api/": "http://localhost:9000", + "/ws": "ws://localhost:9000/ws", + }, + fs: { + // Allow serving files from one level up to the project root + allow: ['..'] + } + }, + } + + }, + +}; + +export default config; diff --git a/web/pw-server/tsconfig.json b/web/pw-server/tsconfig.json new file mode 100644 index 0000000..0555d52 --- /dev/null +++ b/web/pw-server/tsconfig.json @@ -0,0 +1,31 @@ +{ + "compilerOptions": { + "moduleResolution": "node", + "module": "es2020", + "lib": ["es2020", "DOM"], + "target": "es2020", + /** + svelte-preprocess cannot figure out whether you have a value or a type, so tell TypeScript + to enforce using \`import type\` instead of \`import\` for Types. + */ + "importsNotUsedAsValues": "error", + "isolatedModules": true, + "resolveJsonModule": true, + /** + To have warnings/errors of the Svelte compiler at the correct position, + enable source maps by default. + */ + "sourceMap": true, + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "baseUrl": ".", + "allowJs": true, + "checkJs": true, + "paths": { + "$lib": ["src/lib"], + "$lib/*": ["src/lib/*"] + } + }, + "include": ["src/**/*.d.ts", "src/**/*.js", "src/**/*.ts", "src/**/*.svelte"] +} |