aboutsummaryrefslogtreecommitdiffstats
path: root/apps/cli/vite.config.mts
blob: 161d206a6a6a519c386806cd9b4441fc85e1363d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// This file is shamelessly copied from immich's CLI vite config
// https://github.com/immich-app/immich/blob/main/cli/vite.config.ts
import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";

export default defineConfig({
  build: {
    rollupOptions: {
      input: "src/index.ts",
      output: {
        dir: "dist",
        format: "es",
        entryFileNames: "index.mjs",
        banner: "#!/usr/bin/env node",
      },
      external: ["node:fs", "node:path", "node:url", "node:process"],
    },
    ssr: true,
    target: "node18",
  },
  ssr: {
    // bundle everything except for Node built-ins
    noExternal: /^(?!node:).*$/,
  },
  plugins: [tsconfigPaths()],
  define: {
    "import.meta.env.CLI_VERSION": JSON.stringify(
      process.env.npm_package_version,
    ),
  },
  esbuild: {
    // Handle shebang in source files
    banner: "",
  },
});