From 6308b80f526890a2c84fac07ac160b5e13b9b9e2 Mon Sep 17 00:00:00 2001 From: Emmanuel Raviart <emmanuel@raviart.com> Date: Thu, 10 Nov 2022 15:46:19 +0100 Subject: [PATCH] Upgrade SvelteKit specific files --- .eslintignore | 13 +++++++++++++ .eslintrc.cjs | 2 +- package.json | 6 +++--- svelte.config.js | 14 +++++++++----- tsconfig.json | 6 +++++- vite.config.js => vite.config.ts | 4 ++-- 6 files changed, 33 insertions(+), 12 deletions(-) create mode 100644 .eslintignore rename vite.config.js => vite.config.ts (87%) diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 000000000..38972655f --- /dev/null +++ b/.eslintignore @@ -0,0 +1,13 @@ +.DS_Store +node_modules +/build +/.svelte-kit +/package +.env +.env.* +!.env.example + +# Ignore files for PNPM, NPM and YARN +pnpm-lock.yaml +package-lock.json +yarn.lock diff --git a/.eslintrc.cjs b/.eslintrc.cjs index c4721b59f..fe58b1d13 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -15,7 +15,7 @@ module.exports = { parser: "@typescript-eslint/parser", parserOptions: { sourceType: "module", - ecmaVersion: 2019, + ecmaVersion: 2020, }, root: true, settings: { diff --git a/package.json b/package.json index 21d6d72ef..a6915da70 100644 --- a/package.json +++ b/package.json @@ -3,10 +3,10 @@ "version": "0.0.288", "scripts": { "build": "NODE_OPTIONS=--max_old_space_size=4096 vite build", - "check": "svelte-check --tsconfig ./tsconfig.json", - "check:watch": "svelte-check --tsconfig ./tsconfig.json --watch", + "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", + "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", "dev": "vite dev", - "format": "prettier --write --plugin-search-dir=. .", + "format": "prettier --plugin-search-dir=. --write .", "lint": "prettier --check --plugin-search-dir=. . && eslint --ignore-path .gitignore .", "preview": "vite preview", "test": "playwright test" diff --git a/svelte.config.js b/svelte.config.js index c518c6f1f..35a6f095d 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -1,13 +1,13 @@ -import node from "@sveltejs/adapter-node" +import adapter from "@sveltejs/adapter-node" import preprocess from "svelte-preprocess" /** @type {import('@sveltejs/kit').Config} */ -const svelteKitConfig = { +const config = { kit: { // By default, `npm run build` will create a standard Node app. // You can create optimized builds for different platforms by // specifying a different adapter - adapter: node({ + adapter: adapter({ precompress: true, }), @@ -19,7 +19,11 @@ const svelteKitConfig = { // Consult https://github.com/sveltejs/svelte-preprocess // for more information about preprocessors - preprocess: [preprocess({})], + preprocess: [ + preprocess({ + postcss: true, + }), + ], } -export default svelteKitConfig +export default config diff --git a/tsconfig.json b/tsconfig.json index 92b24c34f..794b95b64 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,6 +8,10 @@ "resolveJsonModule": true, "skipLibCheck": true, "sourceMap": true, - "strict": false + "strict": true } + // Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias + // + // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes + // from the referenced tsconfig.json - TypeScript does not merge them in } diff --git a/vite.config.js b/vite.config.ts similarity index 87% rename from vite.config.js rename to vite.config.ts index 3d62bc8a7..77b6a0c71 100644 --- a/vite.config.js +++ b/vite.config.ts @@ -1,7 +1,7 @@ import { sveltekit } from "@sveltejs/kit/vite" +import type { UserConfig } from "vite" -/** @type {import('vite').UserConfig} */ -const config = { +const config: UserConfig = { build: { // Increase size of chunks to 5 MB, to be able to import // JSON files extracted from OpenFisca country package. -- GitLab