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/
|
|
|
|
|
2021-03-31 16:48:59 +08:00
|
|
|
export default ({ command, mode }: ConfigEnv): UserConfig => {
|
|
|
|
return {
|
|
|
|
base: "/",
|
|
|
|
plugins: [vue(), vueJsx(), svgBuilder("./src/icons/svg/")],
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
"/@": resolve("src"),
|
2021-04-03 13:37:52 +08:00
|
|
|
"/#": resolve("types"),
|
|
|
|
"/$": resolve("src/cool/modules")
|
2021-03-31 16:48:59 +08:00
|
|
|
}
|
2021-03-30 18:23:08 +08:00
|
|
|
},
|
2021-03-31 16:48:59 +08:00
|
|
|
css: {
|
|
|
|
preprocessorOptions: {
|
|
|
|
scss: {
|
|
|
|
additionalData: "@import './src/assets/css/common.scss';"
|
|
|
|
}
|
|
|
|
}
|
2021-03-30 18:23:08 +08:00
|
|
|
},
|
2021-03-31 16:48:59 +08:00
|
|
|
server: {
|
|
|
|
port: 9000,
|
|
|
|
hmr: {
|
2021-04-02 19:00:16 +08:00
|
|
|
overlay: true
|
2021-03-30 18:23:08 +08:00
|
|
|
},
|
2021-03-31 16:48:59 +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-31 16:48:59 +08:00
|
|
|
},
|
2021-03-30 18:23:08 +08:00
|
|
|
|
2021-03-31 16:48:59 +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-03-31 16:48:59 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2021-04-02 19:00:16 +08:00
|
|
|
build: {
|
|
|
|
sourcemap: false,
|
2021-04-03 13:37:52 +08:00
|
|
|
polyfillDynamicImport: false // 必须为false
|
2021-03-30 18:23:08 +08:00
|
|
|
},
|
2021-04-02 19:00:16 +08:00
|
|
|
optimizeDeps: {
|
|
|
|
exclude: ["vue-demi"]
|
|
|
|
}
|
2021-03-31 16:48:59 +08:00
|
|
|
};
|
|
|
|
};
|