forked from simeydotme/pokemon-cards-css
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
44 lines (40 loc) · 1.02 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
import { defineConfig, loadEnv } from 'vite'
import { svelte } from '@sveltejs/vite-plugin-svelte'
// https://vitejs.dev/config/
export default defineConfig(({mode}) => {
const venv = loadEnv(mode, process.cwd(), '')
const env = Object.keys(venv).filter((item) => item.startsWith("VITE_")).reduce((cur, key) => { return Object.assign(cur, { [key]: venv[key] })}, {}) ;
const htmlPlugin = () => {
return {
name: "html-transform",
transformIndexHtml(html) {
return html.replace(/%(.*?)%/g, function (match, p1) {
return env[p1];
});
},
};
};
return {
optimizeDeps: { // 👈 optimizedeps
esbuildOptions: {
target: 'es2020',
// Node.js global to browser globalThis
define: {
global: 'globalThis'
},
supported: {
bigint: true
},
}
},
build: {
target: 'es2020'
},
plugins: [svelte(), htmlPlugin()],
server: {
watch: {
usePolling: true
}
}
}
});