| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- import vue from '@vitejs/plugin-vue'
- import path from 'path'
- import { ConfigEnv, defineConfig, UserConfigExport } from 'vite'
- import { viteVConsole } from 'vite-plugin-vconsole'
- export default ({ command, mode }: ConfigEnv): UserConfigExport => defineConfig({
- base: '/',
- css: {
- preprocessorOptions: {
- scss: {
- additionalData: '@import "./src/styles/variables";'
- },
- }
- },
- resolve: {
- alias: [
- {
- find: '/@',
- replacement: path.resolve(__dirname, './src'),
- }
- ]
- },
- server: {
- open: true,
- host: '0.0.0.0',
- port: 8080,
- proxy: {
- '/api': {
- // 开启跨域
- changeOrigin: true,
- // 转发地址
- target: 'http://192.168.3.42:6789',
- // 路径重写
- rewrite: (path) => path.replace(/^\/api/, ''),
- }
- }
- },
- build: {
- target: ['es2015'], // 最低支持 es2015
- sourcemap: true
- },
- plugins: [
- vue(),
- viteVConsole({
- entry: path.resolve(__dirname, './src/main.ts'), // 入口文件
- localEnabled: command === 'serve', // serve开发环境下
- // enabled: command !== 'serve' || mode === 'test', // 打包环境下/发布测试包,
- config: { // vconsole 配置项
- maxLogNumber: 1000,
- theme: 'light'
- }
- }),
- ],
- })
|