123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- import { resolve } from "path";
- import { UserConfigExport, ConfigEnv } from "vite";
- import vue from "@vitejs/plugin-vue";
- import vueJsx from "@vitejs/plugin-vue-jsx";
- import { loadEnv } from "./build/utils";
- import { createProxy } from "./build/proxy";
- import { viteMockServe } from "vite-plugin-mock";
- import styleImport from "vite-plugin-style-import";
- const pathResolve = (dir: string): any => {
- return resolve(__dirname, ".", dir);
- };
- const { VITE_PORT, VITE_PUBLIC_PATH, VITE_PROXY, VITE_OPEN } = loadEnv();
- const alias: Record<string, string> = {
- "/@": pathResolve("src"),
- "vue-i18n": "vue-i18n/dist/vue-i18n.cjs.js",
- };
- const root: string = process.cwd();
- export default ({ command }: ConfigEnv): UserConfigExport => {
- let prodMock = true;
- return {
-
- base:
- process.env.NODE_ENV === "production" ? "/manages/" : VITE_PUBLIC_PATH,
- root,
- resolve: {
- alias,
- },
-
- server: {
-
- https: false,
-
- port: VITE_PORT,
-
- proxy: createProxy(VITE_PROXY),
- },
- plugins: [
- vue(),
- vueJsx(),
- styleImport({
- libs: [
-
- {
- libraryName: "element-plus",
- esModule: true,
- ensureStyleFile: true,
- resolveStyle: (name) => {
- return `element-plus/lib/theme-chalk/${name}.css`;
- },
- resolveComponent: (name) => {
- return `element-plus/lib/${name}`;
- },
- },
-
- {
- libraryName: "vxe-table",
- esModule: true,
- resolveComponent: (name) => `vxe-table/es/${name}`,
- resolveStyle: (name) => `vxe-table/es/${name}/style.css`,
- },
- ],
- }),
- viteMockServe({
- mockPath: "mock",
- localEnabled: command === "serve",
- prodEnabled: command !== "serve" && prodMock,
- injectCode: `
- import { setupProdMockServer } from './mockProdServer';
- setupProdMockServer();
- `,
- logger: true,
- }),
- ],
- optimizeDeps: {
- include: [
- "element-plus/lib/locale/lang/zh-cn",
- "element-plus/lib/locale/lang/en",
- ],
- },
- build: {
- brotliSize: false,
-
- chunkSizeWarningLimit: 2000,
- },
- define: {
- __INTLIFY_PROD_DEVTOOLS__: false,
- },
- };
- };
|