import { fileURLToPath, URL } from 'node:url' import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import vueDevTools from 'vite-plugin-vue-devtools' import AutoImport from 'unplugin-auto-import/vite' import Components from 'unplugin-vue-components/vite' import { ElementPlusResolver } from 'unplugin-vue-components/resolvers' import postcsspxtoviewport from 'postcss-px-to-viewport' // https://vite.dev/config/ export default defineConfig({ base:'/', // base:'./', plugins: [ vue(), vueDevTools(), AutoImport({ resolvers: [ElementPlusResolver()], }), Components({ resolvers: [ElementPlusResolver()], }), ], //在这配置插件内容 css: { postcss: { plugins: [ postcsspxtoviewport({ // 要转化的单位 unitToConvert: '375', // UI设计稿的大小 viewportWidth: 1920, // 转换后的精度 unitPrecision: 6, // 转换后的单位 viewportUnit: 'rem', // 字体转换后的单位 fontViewportUnit: 'rem', // 能转换的属性,*表示所有属性,!border表示border不转 propList: ['*'], // 指定不转换为视窗单位的类名, selectorBlackList: ['ignore-'], // 最小转换的值,小于等于1不转 minPixelValue: 1, // 是否在媒体查询的css代码中也进行转换,默认false mediaQuery: false, // 是否转换后直接更换属性值 replace: true, // 忽略某些文件夹下的文件或特定文件,例如 'node_modules' 下的文件 exclude: [], // 包含那些文件或者特定文件 include: [], // 是否处理横屏情况 landscape: false }), ] } } , resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)), 'vue': 'vue/dist/vue.esm-bundler.js' }, }, // build: { // publicDir: 'public' // }, build:{ rollupOptions:{ output:{ chunkFileNames: 'static/js/[name]-[hash].js', entryFileNames: 'static/js/[name]-[hash].js', assetFileNames:'static/[ext]/[name]-[hash][extname]', manualChunks(id) { if (id.includes('element-plus')) { return 'element-plus'; } } } } }, server: { proxy: { '/api': { target: 'https://mall.gpxscs.cn/', changeOrigin: true, secure: true, }, } } })