From 7e9bc4bfdd3a9249fece605df457241f08d88c28 Mon Sep 17 00:00:00 2001 From: gahusb Date: Mon, 27 Apr 2026 08:24:55 +0900 Subject: [PATCH] feat: add Vite config and TypeScript settings for web build --- package-lock.json | 1 + package.json | 1 + tsconfig.json | 21 ++++++++++++--------- tsconfig.node.json | 12 ++++++++++++ vite-env.d.ts | 14 ++++++++++++++ vite.config.ts | 39 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 79 insertions(+), 9 deletions(-) create mode 100644 tsconfig.node.json create mode 100644 vite-env.d.ts create mode 100644 vite.config.ts diff --git a/package-lock.json b/package-lock.json index f2279c6..241d979 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "zustand": "^5.0.12" }, "devDependencies": { + "@emotion/babel-plugin": "^11.13.5", "@types/node": "^22.7.0", "@types/react": "^18.3.12", "@types/react-dom": "^18.3.1", diff --git a/package.json b/package.json index dab1f65..3453ae7 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "zustand": "^5.0.12" }, "devDependencies": { + "@emotion/babel-plugin": "^11.13.5", "@types/node": "^22.7.0", "@types/react": "^18.3.12", "@types/react-dom": "^18.3.1", diff --git a/tsconfig.json b/tsconfig.json index 896a023..dccb0b2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,23 +1,26 @@ { "compilerOptions": { - "target": "ESNext", - "lib": ["ESNext", "DOM"], - "jsx": "react-jsx", - "jsxImportSource": "@emotion/react", + "target": "ES2022", + "lib": ["ES2022", "DOM", "DOM.Iterable"], + "useDefineForClassFields": true, "module": "ESNext", "moduleResolution": "bundler", - "resolveJsonModule": true, "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, "noEmit": true, + "jsx": "react-jsx", + "jsxImportSource": "@emotion/react", "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, "skipLibCheck": true, - "ignoreDeprecations": "6.0", - "types": ["webpack-env"], "baseUrl": ".", "paths": { "@/*": ["./src/*"] } }, - "include": ["**/*.ts", "**/*.tsx"], - "exclude": ["node_modules"] + "include": ["src", "vite-env.d.ts"], + "references": [{ "path": "./tsconfig.node.json" }] } diff --git a/tsconfig.node.json b/tsconfig.node.json new file mode 100644 index 0000000..1a555ac --- /dev/null +++ b/tsconfig.node.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "composite": true, + "skipLibCheck": true, + "module": "ESNext", + "moduleResolution": "bundler", + "allowSyntheticDefaultImports": true, + "strict": true, + "types": ["node"] + }, + "include": ["vite.config.ts"] +} diff --git a/vite-env.d.ts b/vite-env.d.ts new file mode 100644 index 0000000..87b821d --- /dev/null +++ b/vite-env.d.ts @@ -0,0 +1,14 @@ +/// + +declare const __APP_VERSION__: string; + +interface ImportMetaEnv { + readonly VITE_PUBLIC_URL: string; + readonly VITE_AD_ADAPTER: string; + readonly VITE_GA_MEASUREMENT_ID: string; + readonly VITE_ENABLE_PUSH: string; +} + +interface ImportMeta { + readonly env: ImportMetaEnv; +} diff --git a/vite.config.ts b/vite.config.ts new file mode 100644 index 0000000..1d8b721 --- /dev/null +++ b/vite.config.ts @@ -0,0 +1,39 @@ +import { defineConfig } from 'vite'; +import react from '@vitejs/plugin-react'; + +export default defineConfig({ + plugins: [ + react({ + jsxImportSource: '@emotion/react', + babel: { + plugins: ['@emotion/babel-plugin'], + }, + }), + ], + base: './', + resolve: { + alias: { + '@': '/src', + }, + }, + server: { + port: 5173, + strictPort: false, + open: true, + }, + build: { + outDir: 'dist', + sourcemap: true, + rollupOptions: { + output: { + manualChunks: { + 'react-vendor': ['react', 'react-dom'], + 'state': ['zustand'], + }, + }, + }, + }, + define: { + __APP_VERSION__: JSON.stringify(process.env.npm_package_version), + }, +});