fix
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import react from '@vitejs/plugin-react';
|
||||
import path from 'path';
|
||||
|
||||
// 使用 __dirname 需要添加 import.meta.url 的支持
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
@@ -19,13 +18,13 @@ export default defineConfig({
|
||||
'@contexts': path.resolve(__dirname, 'src/contexts'),
|
||||
'@assets': path.resolve(__dirname, 'src/assets'),
|
||||
},
|
||||
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json'] // 添加文件扩展名自动解析
|
||||
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json']
|
||||
},
|
||||
server: {
|
||||
port: 3000,
|
||||
open: true,
|
||||
host: true,
|
||||
strictPort: true,
|
||||
optimizeDeps: {
|
||||
include: ['react-apexcharts', 'apexcharts'],
|
||||
esbuildOptions: {
|
||||
target: 'es2020',
|
||||
},
|
||||
},
|
||||
build: {
|
||||
outDir: 'dist',
|
||||
@@ -34,8 +33,19 @@ export default defineConfig({
|
||||
output: {
|
||||
manualChunks: {
|
||||
vendor: ['react', 'react-dom', 'react-router-dom', 'antd'],
|
||||
charts: ['react-apexcharts', 'apexcharts'],
|
||||
},
|
||||
},
|
||||
},
|
||||
target: 'es2020',
|
||||
commonjsOptions: {
|
||||
include: [/node_modules/],
|
||||
},
|
||||
},
|
||||
server: {
|
||||
port: 3000,
|
||||
open: true,
|
||||
host: true,
|
||||
strictPort: true,
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user