ch-xymy-h5/vite.config.js

62 lines
1.4 KiB
JavaScript

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite'
import AutoImport from 'unplugin-auto-import/vite'
import { VantResolver } from 'unplugin-vue-components/resolvers'
import { fileURLToPath, URL } from 'node:url'
import pxToViewport from 'postcss-px-to-viewport-8-plugin'
import autoprefixer from 'autoprefixer'
export default defineConfig({
server: {
host: '0.0.0.0',
port: 9992,
// 是否开启 https
https: false,
},
plugins: [
vue(
{
template: {
compilerOptions: {
// 忽略wx-open-launch 开头的组件,这些是微信的默认组件
isCustomElement: (tag) => tag.includes('wx-open-launch')
}
}
}
),
Components({
resolvers: [VantResolver()],
}),
AutoImport({
imports: ['vue', 'vue-router'],
resolvers: [VantResolver()],
}),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
css: {
postcss: {
plugins: [
pxToViewport({
viewportWidth: 375,
unitPrecision: 5,
viewportUnit: 'vw',
selectorBlackList: ['ignore', 'tab-bar'],
minPixelValue: 1,
mediaQuery: false,
}),
autoprefixer(),
],
},
preprocessorOptions: {
less: {
javascriptEnabled: true,
},
},
},
})