generated from mantinedev/vite-template
-
Notifications
You must be signed in to change notification settings - Fork 5
/
vite.config.mjs
38 lines (33 loc) · 1018 Bytes
/
vite.config.mjs
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
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import tsconfigPaths from 'vite-tsconfig-paths';
export default defineConfig({
plugins: [react(), tsconfigPaths()],
test: {
globals: true,
environment: 'jsdom',
setupFiles: './vitest.setup.mjs',
},
build: {
rollupOptions: {
output: {
chunkFileNames: 'assets/js/[name]-[hash].js',
entryFileNames: 'assets/js/[name]-[hash].js',
assetFileNames: ({name}) => {
if (name === 'externalImage') {
return "images/src/[name][extname]";
}
if (/\.(gif|jpe?g|png|svg)$/.test(name ?? '')){
return 'assets/images/[name]-[hash][extname]';
}
if (/\.css$/.test(name ?? '')) {
return 'assets/css/[name]-[hash][extname]';
}
// default value
// ref: https://rollupjs.org/guide/en/#outputassetfilenames
return 'assets/[name]-[hash][extname]';
},
},
}
}
});