a reactive (signals based) hypermedia web framework (wip) stormlightlabs.github.io/volt/
hypermedia frontend signals
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 84 lines 2.8 kB view raw
1import path from "node:path"; 2import { fileURLToPath } from "node:url"; 3import { type BuildEnvironmentOptions, defineConfig, type LibraryOptions } from "vite"; 4import { type ViteUserConfig } from "vitest/config"; 5const __dirname = path.dirname(fileURLToPath(import.meta.url)); 6 7const test: ViteUserConfig["test"] = { 8 environment: "jsdom", 9 setupFiles: "./test/setupTests.ts", 10 globals: true, 11 watch: false, 12 exclude: ["**/node_modules/**", "**/dist/**", "**/cli/tests/**"], 13 silent: true, 14 reporters: ["dot"], 15 coverage: { 16 provider: "v8", 17 reporter: ["text", "json-summary", "html", "lcov", "json"], 18 thresholds: { functions: 50, branches: 50 }, 19 include: ["**/src/**"], 20 exclude: ["**/cli/src/**", "**/src/main.ts", "**/src/demo/**"], 21 }, 22}; 23 24const buildOptions = (mode: string): BuildEnvironmentOptions => { 25 const [baseMode, ...flags] = mode.split(":"); 26 const isLibBuild = baseMode === "lib"; 27 const isDemoBuild = baseMode === "demo"; 28 const shouldMinify = flags.includes("min"); 29 const target = flags.find((flag) => flag !== "min") ?? "all"; 30 31 if (isDemoBuild) { 32 return { 33 minify: shouldMinify ? "oxc" : false, 34 outDir: path.resolve(__dirname, "dist-demo"), 35 rollupOptions: { input: path.resolve(__dirname, "index.html") }, 36 }; 37 } 38 39 if (!isLibBuild) return { minify: shouldMinify ? "oxc" : false }; 40 41 const entry: LibraryOptions["entry"] = {}; 42 if (target === "all" || target === "voltx") entry.voltx = path.resolve(__dirname, "src/index.ts"); 43 if (target === "all" || target === "debug") entry.debug = path.resolve(__dirname, "src/debug.ts"); 44 45 if (Object.keys(entry).length === 0) { 46 entry.voltx = path.resolve(__dirname, "src/index.ts"); 47 } 48 49 const lib: BuildEnvironmentOptions["lib"] = { 50 entry, 51 name: "VoltX", 52 formats: ["es"], 53 fileName: (format, entryName) => { 54 const suffix = shouldMinify ? ".min.js" : ".js"; 55 return `${entryName}${suffix}`; 56 }, 57 }; 58 59 const rolldownOptions: BuildEnvironmentOptions["rolldownOptions"] = { 60 output: { assetFileNames: "voltx.[ext]" }, 61 onwarn(warning, warn) { 62 if (warning.code === "UNUSED_EXTERNAL_IMPORT") return; 63 warn(warning); 64 }, 65 }; 66 67 return { minify: shouldMinify ? "oxc" : false, lib, rolldownOptions }; 68}; 69 70export default defineConfig(({ mode }) => ({ 71 resolve: { 72 alias: { 73 "$types": path.resolve(__dirname, "./src/types"), 74 "$volt": path.resolve(__dirname, "./src/index.ts"), 75 "$core": path.resolve(__dirname, "./src/core"), 76 "$plugins": path.resolve(__dirname, "./src/plugins"), 77 "$debug": path.resolve(__dirname, "./src/debug"), 78 "$vebug": path.resolve(__dirname, "./src/debug.ts"), 79 }, 80 }, 81 build: { ...buildOptions(mode), emptyOutDir: false }, 82 test, 83 plugins: [], 84}));