Spaces:
Build error
Build error
Update web/vite.config.js
Browse files- web/vite.config.js +115 -103
web/vite.config.js
CHANGED
|
@@ -1,103 +1,115 @@
|
|
| 1 |
-
/*
|
| 2 |
-
Copyright (C) 2025 QuantumNous
|
| 3 |
-
|
| 4 |
-
This program is free software: you can redistribute it and/or modify
|
| 5 |
-
it under the terms of the GNU Affero General Public License as
|
| 6 |
-
published by the Free Software Foundation, either version 3 of the
|
| 7 |
-
License, or (at your option) any later version.
|
| 8 |
-
|
| 9 |
-
This program is distributed in the hope that it will be useful,
|
| 10 |
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 11 |
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 12 |
-
GNU Affero General Public License for more details.
|
| 13 |
-
|
| 14 |
-
You should have received a copy of the GNU Affero General Public License
|
| 15 |
-
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
| 16 |
-
|
| 17 |
-
For commercial licensing, please contact support@quantumnous.com
|
| 18 |
-
*/
|
| 19 |
-
|
| 20 |
-
import react from '@vitejs/plugin-react';
|
| 21 |
-
import { defineConfig, transformWithEsbuild } from 'vite';
|
| 22 |
-
import pkg from '@douyinfe/vite-plugin-semi';
|
| 23 |
-
import path from 'path';
|
| 24 |
-
const { vitePluginSemi } = pkg;
|
| 25 |
-
|
| 26 |
-
// https://vitejs.dev/config/
|
| 27 |
-
export default defineConfig({
|
| 28 |
-
resolve: {
|
| 29 |
-
alias: {
|
| 30 |
-
'@': path.resolve(__dirname, './src'),
|
| 31 |
-
},
|
| 32 |
-
},
|
| 33 |
-
plugins: [
|
| 34 |
-
{
|
| 35 |
-
name: 'treat-js-files-as-jsx',
|
| 36 |
-
async transform(code, id) {
|
| 37 |
-
if (!/src\/.*\.js$/.test(id)) {
|
| 38 |
-
return null;
|
| 39 |
-
}
|
| 40 |
-
|
| 41 |
-
// Use the exposed transform from vite, instead of directly
|
| 42 |
-
// transforming with esbuild
|
| 43 |
-
return transformWithEsbuild(code, id, {
|
| 44 |
-
loader: 'jsx',
|
| 45 |
-
jsx: 'automatic',
|
| 46 |
-
});
|
| 47 |
-
},
|
| 48 |
-
},
|
| 49 |
-
react(),
|
| 50 |
-
vitePluginSemi({
|
| 51 |
-
cssLayer: true,
|
| 52 |
-
}),
|
| 53 |
-
],
|
| 54 |
-
optimizeDeps: {
|
| 55 |
-
force: true,
|
| 56 |
-
esbuildOptions: {
|
| 57 |
-
loader: {
|
| 58 |
-
'.js': 'jsx',
|
| 59 |
-
'.json': 'json',
|
| 60 |
-
},
|
| 61 |
-
},
|
| 62 |
-
},
|
| 63 |
-
build: {
|
| 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 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
Copyright (C) 2025 QuantumNous
|
| 3 |
+
|
| 4 |
+
This program is free software: you can redistribute it and/or modify
|
| 5 |
+
it under the terms of the GNU Affero General Public License as
|
| 6 |
+
published by the Free Software Foundation, either version 3 of the
|
| 7 |
+
License, or (at your option) any later version.
|
| 8 |
+
|
| 9 |
+
This program is distributed in the hope that it will be useful,
|
| 10 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 11 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 12 |
+
GNU Affero General Public License for more details.
|
| 13 |
+
|
| 14 |
+
You should have received a copy of the GNU Affero General Public License
|
| 15 |
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
| 16 |
+
|
| 17 |
+
For commercial licensing, please contact support@quantumnous.com
|
| 18 |
+
*/
|
| 19 |
+
|
| 20 |
+
import react from '@vitejs/plugin-react';
|
| 21 |
+
import { defineConfig, transformWithEsbuild } from 'vite';
|
| 22 |
+
import pkg from '@douyinfe/vite-plugin-semi';
|
| 23 |
+
import path from 'path';
|
| 24 |
+
const { vitePluginSemi } = pkg;
|
| 25 |
+
|
| 26 |
+
// https://vitejs.dev/config/
|
| 27 |
+
export default defineConfig({
|
| 28 |
+
resolve: {
|
| 29 |
+
alias: {
|
| 30 |
+
'@': path.resolve(__dirname, './src'),
|
| 31 |
+
},
|
| 32 |
+
},
|
| 33 |
+
plugins: [
|
| 34 |
+
{
|
| 35 |
+
name: 'treat-js-files-as-jsx',
|
| 36 |
+
async transform(code, id) {
|
| 37 |
+
if (!/src\/.*\.js$/.test(id)) {
|
| 38 |
+
return null;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
// Use the exposed transform from vite, instead of directly
|
| 42 |
+
// transforming with esbuild
|
| 43 |
+
return transformWithEsbuild(code, id, {
|
| 44 |
+
loader: 'jsx',
|
| 45 |
+
jsx: 'automatic',
|
| 46 |
+
});
|
| 47 |
+
},
|
| 48 |
+
},
|
| 49 |
+
react(),
|
| 50 |
+
vitePluginSemi({
|
| 51 |
+
cssLayer: true,
|
| 52 |
+
}),
|
| 53 |
+
],
|
| 54 |
+
optimizeDeps: {
|
| 55 |
+
force: true,
|
| 56 |
+
esbuildOptions: {
|
| 57 |
+
loader: {
|
| 58 |
+
'.js': 'jsx',
|
| 59 |
+
'.json': 'json',
|
| 60 |
+
},
|
| 61 |
+
},
|
| 62 |
+
},
|
| 63 |
+
build: {
|
| 64 |
+
chunkSizeWarningLimit: 1000,
|
| 65 |
+
rollupOptions: {
|
| 66 |
+
onwarn(warning, warn) {
|
| 67 |
+
// 忽略 lottie-web 和其他库的 eval 警告
|
| 68 |
+
if (warning.code === 'EVAL') {
|
| 69 |
+
return;
|
| 70 |
+
}
|
| 71 |
+
// 忽略循环依赖警告
|
| 72 |
+
if (warning.code === 'CIRCULAR_DEPENDENCY') {
|
| 73 |
+
return;
|
| 74 |
+
}
|
| 75 |
+
warn(warning);
|
| 76 |
+
},
|
| 77 |
+
output: {
|
| 78 |
+
manualChunks: {
|
| 79 |
+
'react-core': ['react', 'react-dom', 'react-router-dom'],
|
| 80 |
+
'semi-ui': ['@douyinfe/semi-icons', '@douyinfe/semi-ui'],
|
| 81 |
+
tools: ['axios', 'history', 'marked'],
|
| 82 |
+
'react-components': [
|
| 83 |
+
'react-dropzone',
|
| 84 |
+
'react-fireworks',
|
| 85 |
+
'react-telegram-login',
|
| 86 |
+
'react-toastify',
|
| 87 |
+
'react-turnstile',
|
| 88 |
+
],
|
| 89 |
+
i18n: [
|
| 90 |
+
'i18next',
|
| 91 |
+
'react-i18next',
|
| 92 |
+
'i18next-browser-languagedetector',
|
| 93 |
+
],
|
| 94 |
+
},
|
| 95 |
+
},
|
| 96 |
+
},
|
| 97 |
+
},
|
| 98 |
+
server: {
|
| 99 |
+
host: '0.0.0.0',
|
| 100 |
+
proxy: {
|
| 101 |
+
'/api': {
|
| 102 |
+
target: 'http://localhost:3000',
|
| 103 |
+
changeOrigin: true,
|
| 104 |
+
},
|
| 105 |
+
'/mj': {
|
| 106 |
+
target: 'http://localhost:3000',
|
| 107 |
+
changeOrigin: true,
|
| 108 |
+
},
|
| 109 |
+
'/pg': {
|
| 110 |
+
target: 'http://localhost:3000',
|
| 111 |
+
changeOrigin: true,
|
| 112 |
+
},
|
| 113 |
+
},
|
| 114 |
+
},
|
| 115 |
+
});
|