comparison 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
comparison
equal deleted inserted replaced
149:5e76bad44a81 150:3ce355e4f388
1 /// <reference types="vitest" />
2
1 import rollupResolve from "@rollup/plugin-node-resolve"; 3 import rollupResolve from "@rollup/plugin-node-resolve";
2 import terser from "@rollup/plugin-terser"; 4 import terser from "@rollup/plugin-terser";
3 import { defineConfig, UserConfigExport } from "vite"; 5 import { defineConfig, UserConfigExport } from "vite";
4 6
5 const config: UserConfigExport = { 7 const config: UserConfigExport = {
8 port: 8001, 10 port: 8001,
9 hmr: { port: 8002, path: "hmr", protocol: "ws" }, 11 hmr: { port: 8002, path: "hmr", protocol: "ws" },
10 fs: { 12 fs: {
11 allow: ["src", "node_modules", "."], 13 allow: ["src", "node_modules", "."],
12 }, 14 },
15 },
16 test: {
17 globals: true,
18 environment: 'jsdom',
13 }, 19 },
14 build: { 20 build: {
15 lib: { 21 lib: {
16 entry: "src/index.ts", 22 entry: "src/index.ts",
17 formats: ["iife"], 23 formats: ["iife"],
39 define: {}, 45 define: {},
40 }; 46 };
41 47
42 export default defineConfig(({ command, mode }) => { 48 export default defineConfig(({ command, mode }) => {
43 if (command === "serve") { 49 if (command === "serve") {
44 (config.define as any)["process"] = { env: {} }; 50 // (config.define as any)["process"] = { env: {} };
45 return config; 51 return config;
46 } else if (command === "build") { 52 } else if (command === "build") {
47 return config; 53 return config;
48 } else { 54 } else {
49 throw new Error(command); 55 throw new Error(command);