2021-03-30 18:23:08 +08:00
|
|
|
import path from "path";
|
2021-10-27 19:15:27 +08:00
|
|
|
import { UserConfig } from "vite";
|
2021-03-30 18:23:08 +08:00
|
|
|
import vue from "@vitejs/plugin-vue";
|
|
|
|
import vueJsx from "@vitejs/plugin-vue-jsx";
|
2021-10-13 16:17:59 +08:00
|
|
|
import viteCompression from "vite-plugin-compression";
|
2021-12-05 23:09:33 +08:00
|
|
|
import { svgBuilder } from "./build/plugins/svg";
|
|
|
|
import { cool } from "./build/plugins/cool";
|
2021-10-13 16:17:59 +08:00
|
|
|
import Components from "unplugin-vue-components/vite";
|
2021-03-30 18:23:08 +08:00
|
|
|
|
|
|
|
function resolve(dir: string) {
|
|
|
|
return path.resolve(__dirname, ".", dir);
|
|
|
|
}
|
|
|
|
|
|
|
|
// https://vitejs.dev/config/
|
|
|
|
|
2021-04-06 00:05:09 +08:00
|
|
|
export default (): UserConfig => {
|
2021-10-27 19:15:27 +08:00
|
|
|
// 请求代理地址
|
|
|
|
const proxy = {
|
|
|
|
"/dev": {
|
2021-12-08 11:38:50 +08:00
|
|
|
// target: "http://127.0.0.1:8001",
|
|
|
|
target: "http://rjjgeibqc2.localtunnel-cool.cool-js.cloud",
|
2021-10-27 19:15:27 +08:00
|
|
|
changeOrigin: true,
|
|
|
|
rewrite: (path: string) => path.replace(/^\/dev/, "")
|
|
|
|
},
|
|
|
|
|
|
|
|
"/pro": {
|
|
|
|
target: "https://show.cool-admin.com",
|
|
|
|
changeOrigin: true,
|
|
|
|
rewrite: (path: string) => path.replace(/^\/pro/, "/api")
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-03-31 16:48:59 +08:00
|
|
|
return {
|
|
|
|
base: "/",
|
2021-12-05 23:09:33 +08:00
|
|
|
plugins: [
|
|
|
|
vue(),
|
|
|
|
viteCompression(),
|
|
|
|
Components(),
|
|
|
|
vueJsx(),
|
|
|
|
svgBuilder("./src/icons/svg/"),
|
|
|
|
cool()
|
|
|
|
],
|
2021-03-31 16:48:59 +08:00
|
|
|
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: {
|
2021-10-13 16:17:59 +08:00
|
|
|
additionalData: `@use "./src/assets/css/element.scss" as *;`
|
2021-03-31 16:48:59 +08:00
|
|
|
}
|
|
|
|
}
|
2021-03-30 18:23:08 +08:00
|
|
|
},
|
2021-03-31 16:48:59 +08:00
|
|
|
server: {
|
2021-12-08 11:38:50 +08:00
|
|
|
port: 9100,
|
2021-10-27 19:15:27 +08:00
|
|
|
proxy,
|
2021-03-31 16:48:59 +08:00
|
|
|
hmr: {
|
2021-04-02 19:00:16 +08:00
|
|
|
overlay: true
|
2021-03-31 16:48:59 +08:00
|
|
|
}
|
|
|
|
},
|
2021-10-27 19:15:27 +08:00
|
|
|
define: {
|
|
|
|
__PROXY_LIST__: JSON.stringify(proxy)
|
|
|
|
},
|
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
|
|
|
};
|
|
|
|
};
|