| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- import { defineConfig,loadEnv } from 'vite';
- import react from '@vitejs/plugin-react-swc';
- import monacoEditorPlugin from 'vite-plugin-monaco-editor';
- import viteCompression from 'vite-plugin-compression';
- import { visualizer } from 'rollup-plugin-visualizer';
- export default defineConfig(({mode})=> {
- const env = loadEnv(mode, process.cwd(), '');
-
- let define = {};
- Object.keys(env).forEach(key => {
- define[`import.meta.env.${key}`] = JSON.stringify(env[key])
- })
- return {
- base: './',
- plugins: [
- react(),
- {
- name: 'less',
- apply: 'build',
- loaders: ['less-loader']
- },
- monacoEditorPlugin({
- languageWorkers: ['editorWorkerService']
- }),
- visualizer({
- open:true,
- gzipSize:true,
- file: "stats.html",
- brotliSize:true
- }),
- viteCompression({
- filter: /\.(js|css|json|txt|ico|svg)(\?.*)?$/i,
- verbose: true,
- disable: false,
- threshold: 1024,
- algorithm: 'gzip',
- ext: '.gz',
- deleteOriginFile: false
- })
- ],
- build: {
- outDir: 'dist',
- minify: 'terser',
- chunkSizeWarningLimit: 2000,
-
- terserOptions: {
- compress: {
- drop_console: true,
- drop_debugger: true
- }
- },
- },
- server: {
- host: '0.0.0.0',
- port: 5173,
- https: false,
- open: false,
- cors: true,
- base: '/',
- headers: {},
- strictPort: false,
- proxy: {
-
- '^/api': {
- target: 'http://172.20.2.23:18084/',
-
- changeOrigin: true,
- rewrite: (path) => path.replace(/^\/api/, "/api"),
- }
- },
- },
- }
- })
|