74 lines
1.7 KiB
JavaScript
74 lines
1.7 KiB
JavaScript
import { fileURLToPath, URL } from 'node:url'
|
|
|
|
import { defineConfig } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import vueJsx from '@vitejs/plugin-vue-jsx'
|
|
import WindiCSS from 'vite-plugin-windicss'
|
|
|
|
import Components from 'unplugin-vue-components/vite';
|
|
import { VantResolver } from 'unplugin-vue-components/resolvers';
|
|
|
|
const path = require('path')
|
|
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
|
|
import hostAPI from './src/config/host.config'
|
|
|
|
import postcssPxtoRem from 'postcss-pxtorem'
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig({
|
|
plugins: [
|
|
vue(),
|
|
vueJsx(),
|
|
WindiCSS(),
|
|
createSvgIconsPlugin({
|
|
iconDirs: [path.resolve(process.cwd(), 'src/icons/svg')],
|
|
symbolId: 'icon-[name]',
|
|
}),
|
|
Components({
|
|
resolvers: [
|
|
VantResolver(),
|
|
],
|
|
}),
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
'@': fileURLToPath(new URL('./src', import.meta.url))
|
|
}
|
|
},
|
|
css: {
|
|
preprocessorOptions: {
|
|
//define global scss variable
|
|
scss: {
|
|
additionalData: `@import "@/assets/css/mixin.scss";`
|
|
}
|
|
},
|
|
postcss: {
|
|
plugins: [
|
|
postcssPxtoRem({
|
|
rootValue({ file }) {
|
|
return file.indexOf('vant') !== -1 ? 37.5 : 75;
|
|
},
|
|
unitPrecision: 5,
|
|
selectorBlackList: [], // 忽略转换正则匹配项
|
|
propList: ['*'],
|
|
replace: true,
|
|
mediaQuery: false,
|
|
minPixelValue: 0
|
|
})
|
|
]
|
|
}
|
|
},
|
|
server: {
|
|
host: '0.0.0.0',
|
|
port: '8080',
|
|
open: false,
|
|
proxy: {
|
|
'/api': {
|
|
target: hostAPI,
|
|
changeOrigin: true,
|
|
// rewrite: (path) => path.replace(/^\/api/, ''),
|
|
},
|
|
}
|
|
},
|
|
})
|