40 lines
1015 B
TypeScript
40 lines
1015 B
TypeScript
import { defineConfig, loadEnv } from "vite";
|
||
import path from "path";
|
||
import plugins from "./.build/plugins";
|
||
|
||
// https://vite.dev/config/
|
||
export default defineConfig((cnf) => {
|
||
const { mode } = cnf;
|
||
const env = loadEnv(mode, process.cwd());
|
||
const { VITE_APP_ENV } = env;
|
||
return {
|
||
base: VITE_APP_ENV === "production" ? "/" : "/",
|
||
plugins: plugins(cnf),
|
||
resolve: {
|
||
alias: {
|
||
"@": path.resolve(__dirname, "./src"),
|
||
},
|
||
},
|
||
css: {
|
||
// css全局变量使用,@/styles/variable.scss文件
|
||
preprocessorOptions: {
|
||
scss: {
|
||
additionalData: '@use "@/styles/var.scss" as *;',
|
||
},
|
||
},
|
||
},
|
||
|
||
server: {
|
||
proxy: {
|
||
// 代理所有以 /prod-api 开头的请求
|
||
"/prod-api": {
|
||
target: "https://ccnetcore.com", // 接口域名
|
||
changeOrigin: true, // 改变源
|
||
secure: false, // 如果目标服务器使用 HTTPS 且证书无效,需要设置为 false
|
||
},
|
||
},
|
||
},
|
||
|
||
};
|
||
});
|