41 lines
1.6 KiB
TypeScript
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 }) => {
|
|
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(), 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),
|
|
),
|
|
},
|
|
],
|
|
},
|
|
};
|
|
});
|