import { defineConfig } from "vite"; import vue from "@vitejs/plugin-vue"; import { resolve } from "path"; import fs from "fs"; import dotenv from "dotenv"; import postCssPxToRem from "postcss-pxtorem"; // https://vitejs.dev/config/ export default defineConfig(({ mode }) => { console.log("mode", mode); const ASR_ENV = dotenv.parse(fs.readFileSync(`.env.${mode}`)); console.log("ASR_ENV", ASR_ENV); return { plugins: [vue()], assetsInclude: ["**/*.mov"], base: "/sgdaping/", //publicDir:'dist/sgshow', build: { outDir: "dist/sgdaping", }, css: { postcss: { plugins: [ postCssPxToRem({ rootValue: 192, // 1rem的大小 propList: ["*",'!border'], // 需要转换的属性,这里选择全部都进行转换 }), ], }, }, server: { port: 3000, open: true, //https: true, //cors: true, proxy: { // [ASR_ENV.VITE_BASE_API]: { // target: `${ASR_ENV.VITE_TARGET_HOST}`, // changeOrigin: true, // }, "/sgdaping/duoduo-service": { target: "https://duoduoenv.sagacloud.cn", changeOrigin: true, rewrite: (path) => path.replace( /^\/sgdaping\/duoduo-service/, "/duoduo-service" ), }, }, }, resolve: { alias: { "@": resolve(__dirname, ".", "src"), }, }, }; });