-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.mts
More file actions
73 lines (68 loc) · 1.74 KB
/
vite.config.mts
File metadata and controls
73 lines (68 loc) · 1.74 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/// <reference types="vitest" />
/// <reference types="vite/client" />
import { fileURLToPath } from "node:url";
import tailwindcss from "@tailwindcss/vite";
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";
import { featureFlagsPlugin } from "./scripts/vite-plugin-feature-flags.ts";
export type ViteConfigInput = {
mode: "development" | "production";
};
// https://vitejs.dev/config/
export default (args: ViteConfigInput) => {
const generateScopedName =
args.mode === "development" ? "[local]_[hash:base64:4]" : "[hash:base64:4]";
return defineConfig({
assetsInclude: ["**.*.svg"],
base: "./",
build: {
cssMinify: "esbuild",
emptyOutDir: true,
outDir: "./dist",
target: "es2022",
},
css: {
modules: {
generateScopedName,
localsConvention: "camelCase",
},
},
json: {
stringify: true,
},
logLevel: args.mode === "development" ? "warn" : "silent",
plugins: [
// Feature flags plugin - injects build-time flags for tree-shaking
featureFlagsPlugin({
configPath: "./flipt.yaml",
prefix: "FEATURE_",
verbose: args.mode === "development",
}),
tailwindcss(),
react({
babel: {
plugins: [
[
"babel-plugin-react-compiler",
{
compilationMode: "infer",
},
],
],
},
jsxImportSource:
args.mode === "development"
? "@welldone-software/why-did-you-render"
: "react",
}),
],
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
},
},
server: {
port: 3000,
},
});
};