-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
41 lines (37 loc) · 1.06 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
/// <reference types="vitest" />
import { defineConfig, splitVendorChunkPlugin } from 'vite';
import react from '@vitejs/plugin-react';
import legacy from '@vitejs/plugin-legacy';
import child_process from 'child_process';
import path from 'path';
const hash = child_process.execSync('git describe --always --dirty=-dirty', { encoding: 'utf8' }).replace(/\n$/, '');
const hashify = (name: string): string => name.replace('[hash]', hash);
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
legacy({
targets: ['last 2 versions', 'IE >= 11'],
}),
splitVendorChunkPlugin(),
],
resolve: {
alias: {
'@lib': path.resolve(__dirname, './src/lib'),
},
},
build: {
rollupOptions: {
output: {
entryFileNames: hashify('assets/[name].[hash].js'),
chunkFileNames: hashify('assets/[name].[hash].js'),
assetFileNames: hashify('assets/[name].[hash].[ext]'),
},
},
},
test: {
environment: 'happy-dom',
css: true,
include: ['**/*.spec.{js,ts,jsx,tsx}'],
},
})