123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- import { defineConfig } from 'vite'
- import vue from '@vitejs/plugin-vue'
- import path from 'path'
- 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({
- server: {
- open: true,
- prot: 8088
- },
- resolve: {
- // https://cn.vitejs.dev/config/#resolve-alias
- alias: {
- // 设置路径
- '~': path.resolve(__dirname, './'),
- // 设置别名
- '@': path.resolve(__dirname, './src')
- }
- // https://cn.vitejs.dev/config/#resolve-extensions
- // extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
- },
- optimizeDeps: {
- // 开发时 解决这些commonjs包转成esm包
- include: [
- '@jiaminghi/c-render',
- '@jiaminghi/c-render/lib/plugin/util',
- '@jiaminghi/charts/lib/util/index',
- '@jiaminghi/charts/lib/util',
- '@jiaminghi/charts/lib/extend/index',
- '@jiaminghi/charts',
- '@jiaminghi/color'
- ]
- },
- plugins: [
- vue(),
-
- AutoImport({
- resolvers: [ElementPlusResolver()]
- }),
- Components({
- resolvers: [ElementPlusResolver()]
- })
- ],
- css: {
- postcss: {
- plugins: [
- postcsspxtoviewport({
- unitToConvert: 'px', // 要转化的单位
- // viewportHeight: 1087, // 可选,视口高度,通常不需要设置
- viewportWidth: 3840, // UI设计稿的宽度
- unitPrecision: 4, // 转换后的精度,即小数点位数
- propList: ['*'], // 指定转换的css属性的单位,*代表全部css属性的单位都进行转换
- // viewportUnit: 'vh', // 指定需要转换成的视窗单位,默认vw
- // fontViewportUnit: 'vh', // 指定字体需要转换成的视窗单位,默认vw
- viewportUnit: 'vw', // 指定需要转换成的视窗单位,默认vw
- fontViewportUnit: 'vw', // 指定字体需要转换成的视窗单位,默认vw
- selectorBlackList: [], // 指定不转换为视窗单位的类名,
- minPixelValue: 1, // 默认值1,小于或等于1px则不进行转换
- mediaQuery: true, // 是否在媒体查询的css代码中也进行转换,默认false
- replace: true, // 是否转换后直接更换属性值
- exclude: [/node_modules\/(?!element-plus)/], // 设置忽略文件,用正则做目录名匹配
- landscape: false // 是否处理横屏情况
- })
- ]
- }
- },
- })
|