cool-admin-vue/vite.config.ts

58 lines
1.1 KiB
TypeScript
Raw Normal View History

2021-03-30 18:23:08 +08:00
import path from "path";
2021-04-02 19:00:16 +08:00
import type { UserConfig, ConfigEnv } from "vite";
2021-03-30 18:23:08 +08:00
import vue from "@vitejs/plugin-vue";
import vueJsx from "@vitejs/plugin-vue-jsx";
import { svgBuilder } from "./src/core/utils/svg";
function resolve(dir: string) {
return path.resolve(__dirname, ".", dir);
}
// https://vitejs.dev/config/
export default ({ command, mode }: ConfigEnv): UserConfig => {
return {
base: "/",
plugins: [vue(), vueJsx(), svgBuilder("./src/icons/svg/")],
resolve: {
alias: {
"/@": resolve("src"),
"/#": resolve("types")
}
2021-03-30 18:23:08 +08:00
},
css: {
preprocessorOptions: {
scss: {
additionalData: "@import './src/assets/css/common.scss';"
}
}
2021-03-30 18:23:08 +08:00
},
server: {
port: 9000,
hmr: {
2021-04-02 19:00:16 +08:00
overlay: true
2021-03-30 18:23:08 +08:00
},
proxy: {
"/dev": {
target: "http://127.0.0.1:8001",
changeOrigin: true,
2021-04-02 19:00:16 +08:00
rewrite: (path) => path.replace(/^\/dev/, "")
},
2021-03-30 18:23:08 +08:00
"/pro": {
target: "https://show.cool-admin.com",
changeOrigin: true,
2021-04-02 19:00:16 +08:00
rewrite: (path) => path.replace(/^\/pro/, "/api")
}
}
},
2021-04-02 19:00:16 +08:00
build: {
sourcemap: false,
polyfillDynamicImport: false
2021-03-30 18:23:08 +08:00
},
2021-04-02 19:00:16 +08:00
optimizeDeps: {
exclude: ["vue-demi"]
}
};
};