-
Notifications
You must be signed in to change notification settings - Fork 14
/
vite.config.ts
67 lines (66 loc) · 1.88 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
58
59
60
61
62
63
64
65
66
67
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'
export default defineConfig({
plugins: [
react(),
// Prepend the script if it is not a production environment and the React developer tools are enabled
// See:
// https://github.com/facebook/react/tree/main/packages/react-devtools#usage-with-react-dom
// https://vitejs.dev/guide/api-plugin.html#transformindexhtml
{
name: 'react-devtools-script-plugin',
transformIndexHtml () {
// Example usage:
// Default url:
// REACT_DEVTOOLS=1 pnpm tauri dev
// Custom url:
// REACT_DEVTOOLS_URL=http://localhost:4567 pnpm tauri dev
//
if (process.env.NODE_ENV !== 'production' &&
(process.env.REACT_DEVTOOLS === '1' ||
typeof process.env.REACT_DEVTOOLS_URL !== 'undefined')
) {
return [{
injectTo: 'head-prepend',
tag: 'script',
attrs: {
src: process.env.REACT_DEVTOOLS_URL || 'http://localhost:8097'
}
}]
}
}
}
],
define: {
__APP_VERSION__: `"${process.env.npm_package_version}"`,
__APP_DESCRIPTION__: `"${process.env.npm_package_description}"`,
__APP_AUTHOR__: `"${process.env.npm_package_author}"`,
__APP_HOMEPAGE__: `"${process.env.npm_package_homepage}"`,
__APP_REPOSITORY__: `"${process.env.npm_package_repository}"`
},
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
alias: {
'@': path.resolve(__dirname, 'src')
}
},
clearScreen: false,
server: {
port: 1420,
strictPort: true
},
envPrefix: [
'VITE_',
'TAURI_'
],
build: {
target: [
'es2021',
'chrome100',
'safari13'
],
minify: !process.env.TAURI_DEBUG ? 'esbuild' : false,
sourcemap: !!process.env.TAURI_DEBUG
}
})