mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-02-01 08:05:07 +08:00
Refactor: UmiJs -> Vite (#12410)
### What problem does this PR solve? Refactor: UmiJs -> Vite+React ### Type of change - [x] Refactoring --------- Co-authored-by: Liu An <asiro@qq.com>
This commit is contained in:
126
web/vite.config.ts
Normal file
126
web/vite.config.ts
Normal file
@ -0,0 +1,126 @@
|
||||
import { inspectorServer } from '@react-dev-inspector/vite-plugin';
|
||||
import react from '@vitejs/plugin-react';
|
||||
import path from 'path';
|
||||
import { defineConfig, loadEnv } from 'vite';
|
||||
import { createHtmlPlugin } from 'vite-plugin-html';
|
||||
import { viteStaticCopy } from 'vite-plugin-static-copy';
|
||||
import { appName } from './src/conf.json';
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig(({ mode, command }) => {
|
||||
const env = loadEnv(mode, process.cwd(), '');
|
||||
|
||||
return {
|
||||
plugins: [
|
||||
react(),
|
||||
viteStaticCopy({
|
||||
targets: [
|
||||
{
|
||||
src: 'src/conf.json',
|
||||
dest: './',
|
||||
},
|
||||
{
|
||||
src: 'node_modules/monaco-editor/min/vs/',
|
||||
dest: './',
|
||||
},
|
||||
],
|
||||
}),
|
||||
createHtmlPlugin({
|
||||
inject: {
|
||||
data: {
|
||||
title: appName,
|
||||
},
|
||||
},
|
||||
}),
|
||||
inspectorServer(),
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': path.resolve(__dirname, './src'),
|
||||
'@parent': path.resolve(__dirname, '../'),
|
||||
},
|
||||
},
|
||||
css: {
|
||||
modules: {
|
||||
localsConvention: 'camelCase',
|
||||
},
|
||||
postcss: './postcss.config.js',
|
||||
preprocessorOptions: {
|
||||
less: {
|
||||
javascriptEnabled: true,
|
||||
additionalData: `
|
||||
@import "@/less/variable.less";
|
||||
@import "@/less/mixins.less";
|
||||
`,
|
||||
modifyVars: {
|
||||
hack: `true; @import "@/less/index.less";`,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
server: {
|
||||
port: 9222,
|
||||
proxy: {
|
||||
'/api/v1/admin': {
|
||||
target: 'http://127.0.0.1:9381/',
|
||||
changeOrigin: true,
|
||||
ws: true,
|
||||
},
|
||||
'^/(api|v1)': {
|
||||
target: 'http://127.0.0.1:9380/',
|
||||
changeOrigin: true,
|
||||
ws: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
define: {
|
||||
'process.env.UMI_APP_RAGFLOW_ENTERPRISE': JSON.stringify(
|
||||
env.UMI_APP_RAGFLOW_ENTERPRISE,
|
||||
),
|
||||
},
|
||||
assetsInclude: ['**/*.md'],
|
||||
base: env.VITE_BASE_URL,
|
||||
publicDir: 'public',
|
||||
build: {
|
||||
outDir: 'dist',
|
||||
assetsDir: 'assets',
|
||||
assetsInlineLimit: 4096,
|
||||
experimentalMinChunkSize: 30 * 1024,
|
||||
rollupOptions: {
|
||||
output: {
|
||||
chunkFileNames: 'chunk/js/[name]-[hash].js',
|
||||
entryFileNames: 'entry/js/[name]-[hash].js',
|
||||
assetFileNames: 'assets/[ext]/[name]-[hash].[ext]',
|
||||
},
|
||||
plugins: [],
|
||||
},
|
||||
minify: 'terser',
|
||||
terserOptions: {
|
||||
compress: {
|
||||
drop_console: true, // delete console
|
||||
drop_debugger: true, // delete debugger
|
||||
pure_funcs: ['console.log'],
|
||||
},
|
||||
mangle: {
|
||||
// properties: {
|
||||
// regex: /^_/,
|
||||
// },
|
||||
properties: false,
|
||||
},
|
||||
format: {
|
||||
comments: false, // Delete comments
|
||||
},
|
||||
},
|
||||
sourcemap: true,
|
||||
},
|
||||
esbuild: {
|
||||
tsconfigRaw: {
|
||||
compilerOptions: {
|
||||
strict: false,
|
||||
noImplicitAny: false,
|
||||
skipLibCheck: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user