-
Notifications
You must be signed in to change notification settings - Fork 5
/
vite.config.ts
57 lines (56 loc) · 1.65 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
import { defineConfig, loadEnv } from 'vite';
import react from '@vitejs/plugin-react-swc';
import { resolve } from 'path';
import svgr from 'vite-plugin-svgr';
import { nodePolyfills } from 'vite-plugin-node-polyfills';
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
return {
base: '/',
build: {
outDir: 'build',
},
plugins: [
react(),
svgr({
include: '**/*.svg?react',
}),
nodePolyfills(),
],
envPrefix: 'REACT_APP_',
css: {
preprocessorOptions: {
scss: {
// @note 06/09/2024
// This is a temporary fix to allow for importing SCSS files from node_modules
// using the ~ prefix, which is a common convention in sass-loader
importer(url) {
if (url.startsWith('~')) {
return { file: resolve(__dirname, 'node_modules', url.substring(1)) };
}
return { file: url };
},
},
},
},
define: {
'process.env': { ...process.env, ...loadEnv(mode, process.cwd(), '') },
},
resolve: {
alias: {
react: resolve('./node_modules/react'),
'react-dom': resolve('./node_modules/react-dom'),
'react-router': resolve('./node_modules/react-router'),
'react-router-dom': resolve('./node_modules/react-router-dom'),
'@zer0-os/zos-component-library': resolve('./node_modules/@zer0-os/zos-component-library'),
},
},
test: {
// Only run test files that match `vitest.test`
include: ['**/*.vitest.*'],
globals: true,
environment: 'jsdom',
setupFiles: ['./setupVitest.ts'],
},
};
});