59 lines
1.4 KiB
TypeScript
59 lines
1.4 KiB
TypeScript
import { defineConfig } from 'vite'
|
|
import react from '@vitejs/plugin-react'
|
|
import AutoImport from 'unplugin-auto-import/vite'
|
|
import svgr from 'vite-plugin-svgr'
|
|
import { CodeInspectorPlugin } from 'code-inspector-plugin'
|
|
|
|
import path from 'path'
|
|
|
|
// const host = process.env.TAURI_DEV_HOST;
|
|
const host = '127.0.0.1'
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig(async () => ({
|
|
plugins: [
|
|
react(),
|
|
AutoImport({
|
|
dts: './auto-imports.d.ts', //此文件配置保存后系统自动生成
|
|
imports: [
|
|
'react', // 自动导入 React
|
|
],
|
|
}),
|
|
svgr({ include: '**/*.svg?react' }),
|
|
CodeInspectorPlugin({
|
|
bundler: 'vite',
|
|
}),
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, './src'),
|
|
'package.json': path.resolve(__dirname, './package.json'),
|
|
},
|
|
},
|
|
|
|
build: {
|
|
sourcemap: true,
|
|
},
|
|
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
|
|
//
|
|
// 1. prevent vite from obscuring rust errors
|
|
clearScreen: false,
|
|
// 2. tauri expects a fixed port, fail if that port is not available
|
|
server: {
|
|
port: 1420,
|
|
strictPort: true,
|
|
host: host,
|
|
hmr: host
|
|
? {
|
|
protocol: 'ws',
|
|
host,
|
|
port: 1421,
|
|
}
|
|
: undefined,
|
|
watch: {
|
|
// 3. tell vite to ignore watching `src-tauri`
|
|
ignored: ['**/src-tauri/**'],
|
|
},
|
|
},
|
|
}))
|