-
Notifications
You must be signed in to change notification settings - Fork 5
/
vite.config.ts
60 lines (56 loc) · 1.92 KB
/
vite.config.ts
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
import { execSync } from 'child_process';
import { createRequire } from 'node:module';
/// <reference types="vitest" />
import react from '@vitejs/plugin-react-swc';
import { visualizer } from 'rollup-plugin-visualizer';
import { defineConfig, loadEnv, normalizePath } from 'vite';
import { createHtmlPlugin } from 'vite-plugin-html';
import { viteStaticCopy } from 'vite-plugin-static-copy';
import svgr from 'vite-plugin-svgr';
import * as path from 'node:path';
const require = createRequire(import.meta.url);
const cMapsDir = normalizePath(path.join(path.dirname(require.resolve('pdfjs-dist/package.json')), 'cmaps'));
const standardFontsDir = normalizePath(
path.join(path.dirname(require.resolve('pdfjs-dist/package.json')), 'standard_fonts'),
);
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd());
// Make sure release is set client-side, automatic release tagging did not work
process.env.VITE_SENTRY_RELEASE = execSync('git rev-parse HEAD').toString().trim();
return {
build: {
manifest: 'asset-manifest.json',
outDir: 'build',
sourcemap: true,
},
plugins: [
react(),
svgr(),
createHtmlPlugin({
minify: true,
inject: {
data: {
VITE_DEKORATOREN_URL: env.VITE_DEKORATOREN_URL,
},
},
}),
visualizer({
filename: 'bundle-stats.html',
}),
viteStaticCopy({
targets: [
{ src: cMapsDir, dest: '' },
{ src: standardFontsDir, dest: '' },
],
}),
],
server: {
port: 3000,
},
test: {
environment: 'jsdom',
globals: true,
setupFiles: ['./src/setupTests.jsx'],
},
};
});