/* //eg: export default ({ mode }) => { process.env = { ...process.env, ...loadEnv(mode, process.cwd()) }; // import.meta.env.VITE_NAME available here with: process.env.VITE_NAME // import.meta.env.VITE_PORT available here with: process.env.VITE_PORT const plugins = mode === 'development' ? [reactRefresh()] : []; return defineConfig({ plugins, publicDir: 'src/assets', resolve: { alias: aliases, }, build: { chunkSizeWarningLimit: 1500, }, }); }; */ // vite.config.js 利害浏览器自带的 es 动态导入,使项目冷启动 const { resolve } = require('path'); import { defineConfig, loadEnv } from 'vite' // import vue from '@vitejs/plugin-vue' //(1) import { createVuePlugin } from "vite-plugin-vue2"; import vueJsx from '@vitejs/plugin-vue-jsx' const pageage = require("./package.json"); let build = { sourcemap: false, //编译 //指定 多个 .html 文件作为入口点 rollupOptions: { // 请确保外部化那些你的库中不需要的依赖 // external: ['vue'], input: { main: resolve(__dirname, 'index.html'), nested: resolve(__dirname, 'nested/index.html') }, output: { format: 'umd', } } } // https://vitejs.dev/config/ export default ({ mode }) => { process.env = { ...process.env, ...loadEnv(mode, process.cwd()) }; let aliases={} if(mode == 'development'){ aliases= { '@main': resolve(`${pageage.name=='hi-vui-template'?'project':pageage.name}/hivuiMain`), } console.log('aliases@main:', aliases['@main']); }else{ } return defineConfig({ build: build, css: { preprocessorOptions: { less: { javascriptEnabled: true, } }, }, resolve: { extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue', '.dtvevt', '.dtv'], alias:aliases, }, plugins: [ createVuePlugin(), vueJsx({ // options are passed on to @vue/babel-plugin-jsx }) ], optimizeDeps: { // exclude:["hi-ui"],//冷启动时,排除的包 }, devServer: { port: 227, proxy: 'http://192.168.1.183:5001/' } }) };