SolidJSS
SolidJS2y ago
30 replies
Enrypase

defineConfig import.meta.dev

Hi Everybody!
I need to archive a (theoretically) easy thing.

In my defineConfig inside of app.config.ts, I need to resolve a variable based on if I'm running the server with bun run dev or with bun start.

The problem is that, I can't find the environment variable that tells if I'm running as DEV or as PROD.

In fact import.meta.env doesn't seem to be exporting a DEV or PROD variable.

Is there any way for archiving this?

Sharing the code down here

import { defineConfig } from "@solidjs/start/config";
import { resolve } from "path";
import { env } from "process";

export default defineConfig({
  vite: {
    ssr: {
      external: ["@prisma/client"],
    },
    resolve: {
      alias: {
        ".prisma/client/index-browser":
          "./node_modules/.prisma/client/index-browser.js",
        $fonts: resolve(
          /* import.meta.dev ? */ "/public/fonts" /* : "/fonts" */
        ),
      },
    },
    server: {
      port: parseInt(env.PORT || "3000"),
    },
  },
  server: { preset: env.PRESET || "node-server" },
  middleware: "./src/middleware.ts",
});
Was this page helpful?