From e644f54839ea9dbbab4ebc431ac952912aba3de2 Mon Sep 17 00:00:00 2001 From: marleyrae Date: Sun, 28 May 2023 18:44:18 -0700 Subject: [PATCH] :hammer: chore: Vite + Valet --- .idea/jsLibraryMappings.xml | 6 ++++ .../package-lock.json | 7 ++++ product-preview-card-component/package.json | 1 + product-preview-card-component/tsconfig.json | 14 +++++--- product-preview-card-component/vite.config.ts | 32 +++++++++++++++++++ 5 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 .idea/jsLibraryMappings.xml create mode 100644 product-preview-card-component/vite.config.ts diff --git a/.idea/jsLibraryMappings.xml b/.idea/jsLibraryMappings.xml new file mode 100644 index 0000000..d23208f --- /dev/null +++ b/.idea/jsLibraryMappings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/product-preview-card-component/package-lock.json b/product-preview-card-component/package-lock.json index 1631393..fba142f 100644 --- a/product-preview-card-component/package-lock.json +++ b/product-preview-card-component/package-lock.json @@ -8,6 +8,7 @@ "name": "product-preview-card-component", "version": "0.0.0", "devDependencies": { + "@types/node": "^20.2.5", "typescript": "^5.0.2", "vite": "^4.3.2" } @@ -364,6 +365,12 @@ "node": ">=12" } }, + "node_modules/@types/node": { + "version": "20.2.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.2.5.tgz", + "integrity": "sha512-JJulVEQXmiY9Px5axXHeYGLSjhkZEnD+MDPDGbCbIAbMslkKwmygtZFy1X6s/075Yo94sf8GuSlFfPzysQrWZQ==", + "dev": true + }, "node_modules/esbuild": { "version": "0.17.19", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.17.19.tgz", diff --git a/product-preview-card-component/package.json b/product-preview-card-component/package.json index 573e806..3f1ee3a 100644 --- a/product-preview-card-component/package.json +++ b/product-preview-card-component/package.json @@ -9,6 +9,7 @@ "preview": "vite preview" }, "devDependencies": { + "@types/node": "^20.2.5", "typescript": "^5.0.2", "vite": "^4.3.2" } diff --git a/product-preview-card-component/tsconfig.json b/product-preview-card-component/tsconfig.json index 75abdef..70adff6 100644 --- a/product-preview-card-component/tsconfig.json +++ b/product-preview-card-component/tsconfig.json @@ -3,21 +3,25 @@ "target": "ES2020", "useDefineForClassFields": true, "module": "ESNext", - "lib": ["ES2020", "DOM", "DOM.Iterable"], + "lib": [ + "ES2020", + "DOM", + "DOM.Iterable" + ], "skipLibCheck": true, - /* Bundler mode */ - "moduleResolution": "bundler", + "moduleResolution": "node", "allowImportingTsExtensions": true, "resolveJsonModule": true, "isolatedModules": true, "noEmit": true, - /* Linting */ "strict": true, "noUnusedLocals": true, "noUnusedParameters": true, "noFallthroughCasesInSwitch": true }, - "include": ["src"] + "include": [ + "src" + ] } diff --git a/product-preview-card-component/vite.config.ts b/product-preview-card-component/vite.config.ts new file mode 100644 index 0000000..3c21e9e --- /dev/null +++ b/product-preview-card-component/vite.config.ts @@ -0,0 +1,32 @@ +import * as fs from 'fs'; +import { homedir } from 'os'; +import { resolve } from 'path'; +import { defineConfig } from 'vite'; + +export default defineConfig({ + server: detectServerConfig('frontend-mentor.test'), +}); + +function detectServerConfig(host: string) { + const keyPath = resolve(homedir(), `.config/valet/Certificates/${host}.key`); + const certificatePath = resolve(homedir(), `.config/valet/Certificates/${host}.crt`); + + if (!fs.existsSync(keyPath)) { + return {}; + } + + if (!fs.existsSync(certificatePath)) { + return {}; + } + + return { + host: host, + hmr: { + host: host, + }, + https: { + key: fs.readFileSync(keyPath), + cert: fs.readFileSync(certificatePath), + }, + }; +}