From 9361ea9df55713230b9255bab9fbc8aaac31cae7 Mon Sep 17 00:00:00 2001 From: mutoe Date: Wed, 6 Sep 2023 19:55:16 +0800 Subject: [PATCH] chore: update vite project --- cypress.config.ts | 7 ------- package.json | 14 ++++++-------- src/vite-env.d.ts | 1 + tsconfig.app.json | 14 -------------- tsconfig.config.json | 8 -------- tsconfig.cypress-ct.json | 17 ----------------- tsconfig.json | 35 +++++++++++++++++++++++------------ tsconfig.node.json | 10 ++++++++++ vite.config.ts | 4 ++-- 9 files changed, 42 insertions(+), 68 deletions(-) create mode 100644 src/vite-env.d.ts delete mode 100644 tsconfig.app.json delete mode 100644 tsconfig.config.json delete mode 100644 tsconfig.cypress-ct.json create mode 100644 tsconfig.node.json diff --git a/cypress.config.ts b/cypress.config.ts index 142a030..8fef68f 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -7,11 +7,4 @@ export default defineConfig({ baseUrl: 'http://localhost:4173', defaultCommandTimeout: 8000, }, - component: { - specPattern: 'src/**/*.{cy,spec}.{js,ts,jsx,tsx}', - devServer: { - framework: 'vue', - bundler: 'vite', - }, - }, }) diff --git a/package.json b/package.json index 6a59eec..2568af3 100644 --- a/package.json +++ b/package.json @@ -10,8 +10,8 @@ "lint:script": "eslint \"{src/**/*.{ts,vue},cypress/**/*.ts}\"", "lint:tsc": "vue-tsc --noEmit -p tsconfig.app.json --composite false", "lint": "concurrently \"npm run lint:tsc\" \"npm run lint:script\"", - "test:unit": "cypress open --component", - "test:unit:ci": "cypress run --component --quiet --reporter spec", + "test:unit": "echo \"TODO: migrate to vitest\"", + "test:unit:ci": "echo \"TODO: migrate to vitest\"", "test:e2e": "npm run build && concurrently -rk -s first \"npm run serve\" \"cypress open --e2e -c baseUrl=http://localhost:4137\"", "test:e2e:local": "cypress open --e2e -c baseUrl=http://localhost:5173", "test:e2e:ci": "npm run build && concurrently -rk -s first \"npm run serve\" \"cypress run --e2e -c baseUrl=http://localhost:4137\"", @@ -27,13 +27,11 @@ "vue-router": "^4.1.6" }, "devDependencies": { - "@cypress/vue": "^5.0.3", "@mutoe/eslint-config-preset-vue": "~2.1.2", "@pinia/testing": "^0.0.14", "@testing-library/cypress": "^8.0.7", "@types/marked": "^4.0.8", - "@vitejs/plugin-vue": "^4.0.0", - "@vue/tsconfig": "^0.1.3", + "@vitejs/plugin-vue": "^4.3.4", "concurrently": "^7.6.0", "cypress": "^11.2.0", "eslint": "^8.31.0", @@ -43,9 +41,9 @@ "lint-staged": "^13.1.0", "rollup-plugin-analyzer": "^4.0.0", "swagger-typescript-api": "^12.0.2", - "typescript": "~4.9.4", - "vite": "^4.0.3", - "vue-tsc": "^1.0.19" + "typescript": "~5.0.4", + "vite": "^4.4.9", + "vue-tsc": "^1.8.8" }, "lint-staged": { "src/**/*.{ts,vue}": "eslint --fix", diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts new file mode 100644 index 0000000..11f02fe --- /dev/null +++ b/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/tsconfig.app.json b/tsconfig.app.json deleted file mode 100644 index 1c44cc7..0000000 --- a/tsconfig.app.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "extends": "@vue/tsconfig/tsconfig.web.json", - "include": ["env.d.ts", "src/**/*", "src/**/*.vue"], - "exclude": ["src/**/*.spec.ts", "src/***/*.spec.tsx"], - "compilerOptions": { - "baseUrl": ".", - "lib": ["ESNext", "DOM", "DOM.Iterable"] - }, - "references": [ - { - "path": "./tsconfig.config.json" - } - ] -} diff --git a/tsconfig.config.json b/tsconfig.config.json deleted file mode 100644 index dc94651..0000000 --- a/tsconfig.config.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "@vue/tsconfig/tsconfig.node.json", - "include": ["vite.config.*", "vitest.config.*", "cypress.config.*", ".eslintrc.js"], - "compilerOptions": { - "composite": true, - "types": ["node"] - } -} diff --git a/tsconfig.cypress-ct.json b/tsconfig.cypress-ct.json deleted file mode 100644 index 8d287df..0000000 --- a/tsconfig.cypress-ct.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "extends": "./tsconfig.app.json", - "include": [ - "env.d.ts", - "src/**/*", - "src/**/*.vue", - "cypress/support/component.*", - "cypress/support/commands.ts", - "cypress/fixtures/**/*" - ], - "exclude": [], - "compilerOptions": { - "composite": true, - "types": ["cypress", "@testing-library/cypress"], - "noEmit": true - } -} diff --git a/tsconfig.json b/tsconfig.json index 040665b..f82888f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,14 +1,25 @@ { - "files": [], - "references": [ - { - "path": "./tsconfig.config.json" - }, - { - "path": "./tsconfig.app.json" - }, - { - "path": "./tsconfig.cypress-ct.json" - } - ] + "compilerOptions": { + "target": "ES2020", + "useDefineForClassFields": true, + "module": "ESNext", + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "preserve", + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"], + "references": [{ "path": "./tsconfig.node.json" }] } diff --git a/tsconfig.node.json b/tsconfig.node.json new file mode 100644 index 0000000..42872c5 --- /dev/null +++ b/tsconfig.node.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "composite": true, + "skipLibCheck": true, + "module": "ESNext", + "moduleResolution": "bundler", + "allowSyntheticDefaultImports": true + }, + "include": ["vite.config.ts"] +} diff --git a/vite.config.ts b/vite.config.ts index bcebbc6..c7d4652 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,4 +1,4 @@ -import { fileURLToPath, URL } from 'url' +import { fileURLToPath, URL } from 'node:url' import vue from '@vitejs/plugin-vue' import { defineConfig } from 'vite' import analyzer from 'rollup-plugin-analyzer' @@ -7,7 +7,7 @@ import analyzer from 'rollup-plugin-analyzer' export default defineConfig({ resolve: { alias: { - src: fileURLToPath(new URL('./src', import.meta.url)), + src: fileURLToPath(new URL('src', import.meta.url)), }, }, plugins: [