diff vite.config.ts @ 101:76c1a29a328f

repo now demos itself, which runs better than using the nested demo/ project
author drewp@bigasterisk.com
date Fri, 11 Feb 2022 23:24:41 -0800
parents faf7e432f089
children 73a70d00fb74
line wrap: on
line diff
--- a/vite.config.ts	Fri Feb 11 22:57:23 2022 -0800
+++ b/vite.config.ts	Fri Feb 11 23:24:41 2022 -0800
@@ -1,7 +1,6 @@
-import { defineConfig } from "vite";
+import { defineConfig, UserConfigExport } from "vite";
 
-// https://vitejs.dev/config/
-export default defineConfig({
+const config: UserConfigExport = {
   base: "https://bigasterisk.com/reposyncDev/",
   server: {
     host: "0.0.0.0",
@@ -12,8 +11,7 @@
     },
   },
   build: {
-    target: 'esnext',
-    minify: false,
+    target: "esnext",
     lib: {
       entry: "src/index.ts",
       formats: ["es"],
@@ -26,7 +24,17 @@
     alias: [{ find: "rdf-canonize-native", replacement: "" }],
   },
   define: {
-    "global": {},
-    "process": {"env":{}}, // needed in dev and not build
+    global: {},
   },
+};
+
+export default defineConfig(({ command, mode }) => {
+  if (command === "serve") {
+    (config.define as any)["process"] = { env: {} };
+    return config;
+  } else if (command === "build") {
+    return config;
+  } else {
+    throw new Error(command);
+  }
 });