UNPKG

aqsc-mobile-com

Version:

基于uni-ui实现的二次封装

124 lines (120 loc) 4.42 kB
import { defineConfig, loadEnv } from 'vite' import uni from '@dcloudio/vite-plugin-uni' import AutoImport from 'unplugin-auto-import/vite' // eslint-disable-next-line no-undef const path = require('path') // https://vitejs.dev/config/ export default defineConfig(({ command, mode }) => { // eslint-disable-next-line no-undef const env = loadEnv(mode, process.cwd(), '') return { base: './', server: { open: true, port: 9000, proxy: { '/dev-api/weworkCompany': { target: 'http://10.244.130.168', changeOrigin: true, rewrite: (path) => path.replace(/^\/dev-api\/weworkCompany/, '/prod-api'), }, '/dev-api/jtgs': { target: 'http://10.244.130.168', changeOrigin: true, rewrite: (path) => path.replace(/^\/dev-api\/jtgs/, '/prod-api'), }, // '/dev-api/aqgl': { // target: 'http://10.248.132.74:8099', // changeOrigin: true, // rewrite: (path) => path.replace(/^\/dev-api\/aqgl/, '/dev-api'), // }, // '/dev-api/tpridmp': { // target: 'http://10.248.132.83:8099', // changeOrigin: true, // rewrite: (path) => path.replace(/^\/dev-api\/tpridmp/, '/dev-api/'), // }, // '/dev-api/sjgl': { // target: 'http://10.248.132.193:8099', // changeOrigin: true, // rewrite: (path) => path.replace(/^\/dev-api\/sjgl/, '/dev-api/'), // }, // '/dev-api/yxgl': { // target: 'http://127.0.0.1:8099', // changeOrigin: true, // rewrite: (path) => path.replace(/^\/dev-api\/yxgl/, '/dev-api/'), // }, '/dev-api': { target: 'http://10.244.130.168', changeOrigin: true, rewrite: (path) => path.replace(/^\/dev-api/, '/prod-api'), }, // '/dev-api': { // target: 'https://mobileas.chng.com.cn:8888/', // changeOrigin: true, // rewrite: (path) => path.replace(/^\/dev-api/, '/W040/prod-api'), // }, '/fileservice/': { target: 'http://10.244.130.168', changeOrigin: true, }, }, }, build: { lib: { entry: './src/packages/index.js', //指定组件编译入口文件 name: 'aqscMobileCom', fileName: 'aqsc-mobile-com', }, //库编译模式配置 rollupOptions: { external: ['vue'], output: { // format: 'es', // 默认es,可选 'amd' 'cjs' 'es' 'iife' 'umd' 'system' exports: 'named', globals: { //在UMD构建模式下为这些外部化的依赖提供一个全局变量 vue: 'Vue', }, }, }, /** 设置为 false 可以禁用最小化混淆,或是用来指定使用哪种混淆器。 默认为 Esbuild,它比 terser 快 20-40 倍,压缩率只差 1%-2%。 注意,在 lib 模式下使用 'es' 时,build.minify 选项不会缩减空格,因为会移除掉 pure 标注,导致破坏 tree-shaking。 当设置为 'terser' 时必须先安装 Terser。(yarn add terser -D) */ minify: 'terser', // Vite 2.6.x 以上需要配置 minify: "terser", terserOptions 才能生效 terserOptions: { // 在打包代码时移除 console、debugger 和 注释 compress: { /* (default: false) -- Pass true to discard calls to console.* functions. If you wish to drop a specific function call such as console.info and/or retain side effects from function arguments after dropping the function call then use pure_funcs instead */ drop_console: true, // 生产环境时移除console drop_debugger: true, }, format: { comments: false, // 删除注释comments }, }, }, plugins: [ uni(), AutoImport({ imports: ['vue'], dts: false, eslintrc: { enabled: false, filepath: './.eslintrc-auto-import.json', globalsPropValue: true, }, }), ], resolve: { alias: { // eslint-disable-next-line no-undef '@': path.resolve(__dirname, 'src'), }, }, } })