123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- import { fileURLToPath, URL } from 'node:url'
- import { defineConfig, loadEnv } from 'vite'
- import vue from '@vitejs/plugin-vue'
- import VueDevTools from 'vite-plugin-vue-devtools'
- import VueSetupExtend from 'vite-plugin-vue-setup-extend'
- import autoImport from 'unplugin-auto-import/vite'
- import AutoImport from 'unplugin-auto-import/vite'
- import Components from 'unplugin-vue-components/vite'
- import { VantResolver } from '@vant/auto-import-resolver'
- const createAutoImport = () => {
- return autoImport({
- imports: ['vue', 'vue-router', 'pinia'],
- dts: false
- })
- }
- // https://vitejs.dev/config/
- export default defineConfig(({ mode }) => {
- const env = loadEnv(mode, process.cwd())
- console.log(mode, env)
- const plugins = [
- vue(),
- VueSetupExtend(),
- createAutoImport(),
- AutoImport({
- resolvers: [VantResolver()]
- }),
- Components({
- resolvers: [VantResolver()]
- })
- ]
- if (mode === 'development') {
- plugins.push(VueDevTools())
- }
- return {
- plugins: plugins,
- resolve: {
- alias: {
- '@': fileURLToPath(new URL('./src', import.meta.url))
- }
- },
- server: {
- host: true,
- proxy: {
- '/dev-api': {
- target: 'http://172.16.10.61:8080/prod-api',
- // target: 'https://vue.ruoyi.vip/prod-api',
- changeOrigin: true,
- rewrite: (p) => p.replace(/^\/dev-api/, '')
- }
- }
- },
- //配置sass
- css: {
- preprocessorOptions: {
- scss: {
- additionalData:
- '@import "./src/assets/scss/globalVar.scss";@import "./src/assets/scss/globalMixin.scss";'
- }
- }
- }
- }
- })
|