123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- import { defineConfig, loadEnv } from 'vite';
- import createVitePlugins from './vite/plugins';
- import path from 'path';
- export default defineConfig(({ mode, command }) => {
- const env = loadEnv(mode, process.cwd());
- const { VITE_APP_ENV } = env;
- return {
- plugins: createVitePlugins(env, command === 'build'),
- // 部署生产环境和开发环境下的URL。
- // 默认情况下,vite 会假设你的应用是被部署在一个域名的根路径上
- // 例如 https://www.ruoyi.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.ruoyi.vip/admin/,则设置 baseUrl 为 /admin/。
- base: VITE_APP_ENV === 'production' ? '/' : '/',
- server: {
- port: 80,
- host: true,
- open: true,
- proxy: {
- // https://cn.vitejs.dev/config/#server-proxy
- '/dev-api': {
- target: 'http://localhost:8080',
- changeOrigin: true,
- rewrite: p => p.replace(/^\/dev-api/, ''),
- },
- },
- },
- resolve: {
- alias: {
- // 设置路径
- '~': path.resolve(__dirname, './'),
- // 设置别名
- '@': path.resolve(__dirname, './src'),
- },
- },
- build: {
- // chunkSizeWarningLimit: 1500,
- rollupOptions: {
- output: {
- manualChunks(id) {
- if (id.includes('element-plus/theme')) {
- return 'ele';
- }
- // if (id.includes('node_modules')) {
- // return id.toString().split('node_modules/.pnpm/')[1].split('/').toString();
- // }
- },
- },
- },
- minify: 'terser',
- terserOptions: {
- compress: {
- // eslint-disable-next-line camelcase
- drop_console: true,
- // eslint-disable-next-line camelcase
- drop_debugger: true,
- }
- },
- },
- };
- });
|