Portfolio/vite.config.ts
Matthew L McPeak aecf76becb
All checks were successful
ci / build (push) Successful in 19s
ci / publish (push) Successful in 14s
fix: devTools
2026-07-16 14:14:08 -04:00

41 lines
1.6 KiB
TypeScript

import { fileURLToPath, URL } from "node:url";
import { defineConfig, loadEnv } from "vite";
import vue from "@vitejs/plugin-vue";
import vueDevTools from "vite-plugin-vue-devtools";
import tailwindcss from "@tailwindcss/vite";
// https://vite.dev/config/
export default defineConfig(({ mode, command }) => {
const env = loadEnv(mode, process.cwd(), "VITE");
const baseURL = fileURLToPath(new URL("./src", import.meta.url));
return {
define: {
API_URL: JSON.stringify(env.VITE_API_URL ?? ""),
API_KEY: JSON.stringify(env.VITE_API_KEY ?? ""),
},
plugins: [vue(), ...(command === "serve" ? [vueDevTools()] : []), tailwindcss()],
resolve: {
alias: [
{ find: "@", replacement: baseURL },
{ find: "~", replacement: baseURL },
// @nychthemeron/library's package.json declares a "development"
// export condition pointing at "./src/index.ts", but that file
// isn't included in the published package (only src/assets and
// src/components are) — Vite's dev server picks that condition and
// fails to resolve the bare import. Force just the bare specifier
// (not the /style or /components subpaths, which resolve fine) to
// the same pre-built dist bundle the "import" condition already
// uses for production builds. Anchored regex so it doesn't also
// match (and break) those subpaths via prefix matching.
{
find: /^@nychthemeron\/library$/,
replacement: fileURLToPath(
new URL("./node_modules/@nychthemeron/library/dist/index.js", import.meta.url),
),
},
],
},
};
});