-
Notifications
You must be signed in to change notification settings - Fork 68
/
vite.config.js
91 lines (87 loc) · 1.96 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
79
80
81
82
83
84
85
86
87
88
89
90
91
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import viteTsconfigPaths from 'vite-tsconfig-paths'
import svgrPlugin from 'vite-plugin-svgr'
import { createHtmlPlugin } from 'vite-plugin-html'
import EnvironmentPlugin from 'vite-plugin-environment'
import autoprefixer from 'autoprefixer'
import 'dotenv/config'
// Populate with `version` field of package.json
process.env.VITE_APP_VERSION = process.env.npm_package_version
// https://vitejs.dev/config/
export default defineConfig({
// source code location
root: './src',
// where env vars are stored
envDir: '..',
build: {
// where build files should be stored
outDir: '../build',
// empty the build directory on each build
emptyOutDir: true,
sourcemap: true,
commonjsOptions: {
transformMixedEsModules: true,
},
rollupOptions: {
// improve CPU usage
cache: false,
},
},
// relative to the root
publicDir: '../public',
server: {
// backend settings
open: true,
port: 3000,
proxy: {
'/api': 'http://localhost:5001',
},
},
resolve: {
// polyfills
alias: {
events: 'events',
},
},
optimizeDeps: {
esbuildOptions: {
define: {
// Node.js global to browser globalThis
global: 'globalThis',
},
},
},
plugins: [
// export SVGs as React components by default
svgrPlugin({
svgrOptions: {
ref: true,
},
include: '**/*.svg',
}),
react({
// Use React plugin in all *.jsx and *.tsx files
include: '**/*.{jsx,tsx}',
}),
createHtmlPlugin({
inject: {
data: {
VITE_GTM_ID: process.env.VITE_GTM_ID,
VITE_OSANO_ID: process.env.VITE_OSANO_ID,
},
},
}),
// use env vars
EnvironmentPlugin('all'),
// use TS paths
viteTsconfigPaths(),
],
css: {
postcss: {
plugins: [
autoprefixer({}), // add options if needed
],
},
},
})