-
Notifications
You must be signed in to change notification settings - Fork 5
/
vite.config.js
78 lines (77 loc) · 1.75 KB
/
vite.config.js
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import commonjs from 'vite-plugin-commonjs';
import { viteStaticCopy } from 'vite-plugin-static-copy';
import path from 'path';
import postcssUrl from 'postcss-url';
import babel from '@rollup/plugin-babel';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
viteStaticCopy({
targets: [
{ // copy leaflet-draw images to dist
src: 'node_modules/leaflet-draw/dist/images/*',
dest: 'assets/images'
},
]
}),
react({
jsxRuntime: 'classic',
}),
commonjs(),
babel({
babelHelpers: 'bundled',
extensions: ['.js', '.jsx'],
include: ['node_modules/react-foundation/**'],
only: ['node_modules/react-foundation/**'],
presets: [
'@babel/preset-env',
'@babel/preset-react',
],
}),
],
css: {
postcss: {
plugins: [
postcssUrl({
url: (asset) => {
// transform urls from `node_modules/leaflet-draw/dist/leaflet.draw.css`
// change those urls to point from `/images` to `/assets/images`
if (asset.relativePath && asset.relativePath.startsWith('images/')) {
return `/assets/${asset.url}`;
}
return asset.url;
}
}),
]
}
},
resolve: {
alias: {
'@': path.resolve(__dirname, '/src'),
},},
define: {
'global': {},
},
optimizeDeps: {
esbuildOptions: {
loader: {
'.js': 'jsx',
},
},
},
server: {
port: 3000,
},
test: {
globals: true,
environment: 'jsdom',
alias: {
'@': path.resolve(__dirname, '/src'),
},
coverage: {
provider: 'istanbul'
},
}
})