67 lines
1.5 KiB
JavaScript
67 lines
1.5 KiB
JavaScript
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 { VantResolver } from 'unplugin-vue-components/resolvers'
|
|
// 安装 postcss-pxtorem 和 autoprefixer
|
|
|
|
// npm install postcss-pxtorem --save
|
|
// npm i autoprefixer
|
|
import pxtoviewport from 'postcss-px-to-viewport';
|
|
import autoprefixer from 'autoprefixer';
|
|
import { fileURLToPath, URL } from 'node:url'
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig({
|
|
base:'./',
|
|
plugins: [
|
|
vue(),
|
|
AutoImport({
|
|
imports: ['vue', 'vue-router'],
|
|
}),
|
|
Components({
|
|
resolvers: [VantResolver()],
|
|
// 禁用自动导入样式
|
|
dts: true,
|
|
include: [/\.vue$/, /\.vue\?vue/, /\.md$/],
|
|
exclude: [/node_modules/],
|
|
}),
|
|
],
|
|
// css: {
|
|
|
|
// postcss: {
|
|
// plugins: [
|
|
// autoprefixer(),
|
|
// pxtoviewport({
|
|
// viewportWidth: 375,
|
|
// }),
|
|
// ],
|
|
// },
|
|
|
|
// },
|
|
|
|
server: {
|
|
host: "0.0.0.0",
|
|
port: 8123,
|
|
open: true,
|
|
cors: true,
|
|
proxy: {
|
|
'/api': {
|
|
target: 'http://192.168.1.100:8080',
|
|
changeOrigin: true,
|
|
rewrite: (path) => path.replace(/^\/api/, '')
|
|
}
|
|
}
|
|
},
|
|
resolve: {
|
|
alias:{
|
|
// 配置src目录
|
|
"@": fileURLToPath(new URL('./src', import.meta.url)),
|
|
// 导入其他目录
|
|
"components": path.resolve(__dirname, "components"),
|
|
|
|
}
|
|
},
|
|
|
|
})
|