view vite.config.ts @ 150:3ce355e4f388 default tip

bye jest; hi vitest. new working test for styles.ts
author drewp@bigasterisk.com
date Mon, 08 May 2023 17:27:44 -0700
parents c26538ee1d1d
children
line wrap: on
line source

/// <reference types="vitest" />

import rollupResolve from "@rollup/plugin-node-resolve";
import terser from "@rollup/plugin-terser";
import { defineConfig, UserConfigExport } from "vite";

const config: UserConfigExport = {
  server: {
    host: "0.0.0.0",
    port: 8001,
    hmr: { port: 8002, path: "hmr", protocol: "ws" },
    fs: {
      allow: ["src", "node_modules", "."],
    },
  },
  test: {
    globals: true,
    environment: 'jsdom',
  },
  build: {
    lib: {
      entry: "src/index.ts",
      formats: ["iife"],
      name: "streamedgraph",
    },
    minify: false,
    rollupOptions: {
      plugins: [
        rollupResolve({
          browser: true,
          preferBuiltins: false,
        }),
        terser({
          mangle: true,
          compress: false,
          format: {
            semicolons: false,
          },
        }),
      ],
    },
    sourcemap: true,
    target: "esnext",
  },
  define: {},
};

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);
  }
});