ai-vue3-admin/vite.config.js
2021-04-14 11:08:41 +08:00

49 lines
1.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from "path";
import { viteMockServe } from "vite-plugin-mock";
import viteSvgIcons from 'vite-plugin-svg-icons';
// https://vitejs.dev/config/
export default env => {
// console.log(111, env);
return defineConfig({
plugins: [
vue(),
viteMockServe({
mockPath: "mock", // 指定mock目录中的文件全部是mock接口
localEnabled: env.mode === "mock", // 指定在mock模式下才启动mock服务可以在package.json的启动命令中指定mode为mock
supportTs: false, // mockPath目录中的文件是否支持ts文件现在我们不使用ts所以设为false
}),
viteSvgIcons({
// 指定需要缓存的图标文件夹
iconDirs: [path.resolve(__dirname, 'src/assets/svg')],
// 指定symbolId格式
symbolId: 'icon-[dir]-[name]',
}),
],
css: {
preprocessorOptions: {
scss: {
additionalData: '@import "./src/assets/style/global-variables.scss";' // 全局变量
}
}
},
resolve: {
alias: {
"@": path.resolve(__dirname, "src"),
},
},
server: {
port: 8080,
open: true,
proxy: {
"/api": {
target: "http://dev.erp.com",
changeOrigin: true,
},
},
},
});
};