-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
55 lines (50 loc) · 1.51 KB
/
Copy pathvite.config.ts
File metadata and controls
55 lines (50 loc) · 1.51 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
import path from "path"
import fs from "fs"
import { defineConfig, UserConfig } from 'vite'
import react from '@vitejs/plugin-react'
import tailwindcss from "@tailwindcss/vite"
const readWfcVersion = (): string => {
const pomPath = path.resolve(__dirname, "../pom.xml");
const pom = fs.readFileSync(pomPath, "utf8");
const match = pom.match(/<artifactId>commons<\/artifactId>\s*<version>([^<]+)<\/version>/);
if (!match) throw new Error(`Could not find project <version> in ${pomPath}`);
return match[1];
};
const WFC_VERSION = readWfcVersion();
// https://vite.dev/config/
export default defineConfig({
plugins: [react(), tailwindcss()],
define: {
__WFC_VERSION__: JSON.stringify(WFC_VERSION),
},
test: {
globals: true,
environment: 'happy-dom',
setupFiles: ['./src-e2e/setup.ts'],
include: ['./src-e2e/**/*.{test,spec}.{ts,tsx}'],
},
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
build: {
outDir: '../target/classes/webreport',
rollupOptions: {
output: {
entryFileNames: `assets/report.js`,
chunkFileNames: `assets/[name].js`,
assetFileNames: (assetInfo: { name: string }) => {
const extType = assetInfo.name.split('.').pop();
if (extType === 'css') {
return `assets/report.css`;
}
if (extType === 'svg') {
return `assets/[name].svg`;
}
return `assets/[name].[ext]`;
}
}
}
},
} as UserConfig)