From bcdc53505eb5f3b65ae9482175d0477e4987b196 Mon Sep 17 00:00:00 2001 From: CatWithFish <72800755+Muyu-art@users.noreply.github.com> Date: Wed, 21 Aug 2024 09:44:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20vue2=E5=A4=9A=E6=89=93=E5=8C=85vite/rsp?= =?UTF-8?q?ack/webpack=20(#171)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: vue2多打包vite/rspack/webpack * fix: 检视意见修改 --- packages/toolkits/pro/template/tinyvue2/.env | 2 +- .../vite.config.base.ts} | 25 +-- .../tinyvue2/config/vite.config.dev.ts | 23 +++ .../tinyvue2/config/vite.config.prod.ts | 18 ++ .../pro/template/tinyvue2/package.json | 31 +++- .../pro/template/tinyvue2/rspack.config.js | 163 +++++++++++++++++ .../pro/template/tinyvue2/src/api/list.ts | 2 +- .../tinyvue2/src/router/guard/menu.ts | 2 +- .../tinyvue2/src/router/guard/permission.ts | 6 + .../tinyvue2/src/router/routes/index.ts | 7 +- .../src/views/login/components/login-mail.vue | 21 ++- .../src/views/userManager/setting/index.vue | 1 - .../template/tinyvue2/tsconfig.config.json | 2 +- .../pro/template/tinyvue2/webpack.config.js | 168 ++++++++++++++++++ 14 files changed, 429 insertions(+), 42 deletions(-) rename packages/toolkits/pro/template/tinyvue2/{vite.config.ts => config/vite.config.base.ts} (55%) create mode 100644 packages/toolkits/pro/template/tinyvue2/config/vite.config.dev.ts create mode 100644 packages/toolkits/pro/template/tinyvue2/config/vite.config.prod.ts create mode 100644 packages/toolkits/pro/template/tinyvue2/rspack.config.js create mode 100644 packages/toolkits/pro/template/tinyvue2/webpack.config.js diff --git a/packages/toolkits/pro/template/tinyvue2/.env b/packages/toolkits/pro/template/tinyvue2/.env index 27a9a3e9..96830288 100644 --- a/packages/toolkits/pro/template/tinyvue2/.env +++ b/packages/toolkits/pro/template/tinyvue2/.env @@ -5,4 +5,4 @@ VITE_MOCK_HOST= http://127.0.0.1:8848 VITE_USE_MOCK= false VITE_MOCK_IGNORE= /api/user/userInfo,/api/user/login,/api/user/register,/api/employee/getEmployee -VITE_MOCK_SERVER_HOST=/mock +VITE_MOCK_SERVER_HOST=/mock \ No newline at end of file diff --git a/packages/toolkits/pro/template/tinyvue2/vite.config.ts b/packages/toolkits/pro/template/tinyvue2/config/vite.config.base.ts similarity index 55% rename from packages/toolkits/pro/template/tinyvue2/vite.config.ts rename to packages/toolkits/pro/template/tinyvue2/config/vite.config.base.ts index cd8f6884..707733b7 100644 --- a/packages/toolkits/pro/template/tinyvue2/vite.config.ts +++ b/packages/toolkits/pro/template/tinyvue2/config/vite.config.base.ts @@ -1,19 +1,12 @@ -import { fileURLToPath, URL } from 'node:url'; - import { defineConfig } from 'vite'; -import legacy from '@vitejs/plugin-legacy'; +import { fileURLToPath, URL } from 'node:url'; import vue2 from '@vitejs/plugin-vue2'; import { resolve } from 'node:path'; import { viteMockServe } from 'vite-plugin-mock'; -// https://vitejs.dev/config/ export default defineConfig({ plugins: [ vue2(), - legacy({ - targets: ['ie >= 11'], - additionalLegacyPolyfills: ['regenerator-runtime/runtime'], - }), viteMockServe({ mockPath: './src/mock', enable: true, @@ -21,7 +14,7 @@ export default defineConfig({ ], resolve: { alias: { - '@': fileURLToPath(new URL('./src', import.meta.url)), + '@': fileURLToPath(new URL('../src', import.meta.url)), }, }, define: { @@ -40,18 +33,4 @@ export default defineConfig({ }, }, }, - server: { - proxy: { - '/api': { - target: 'http://127.0.0.1:3000', - changeOrigin: true, - rewrite: (path) => path.replace(/^\/api/, ''), - }, - '/mock': { - target: 'http://127.0.0.1:8848', - changeOrigin: true, - rewrite: (path) => path.replace(/^\/mock/, ''), - }, - }, - }, }); diff --git a/packages/toolkits/pro/template/tinyvue2/config/vite.config.dev.ts b/packages/toolkits/pro/template/tinyvue2/config/vite.config.dev.ts new file mode 100644 index 00000000..9ff3c5c5 --- /dev/null +++ b/packages/toolkits/pro/template/tinyvue2/config/vite.config.dev.ts @@ -0,0 +1,23 @@ +import { mergeConfig } from 'vite'; +import baseConfig from './vite.config.base'; + +const proxyConfig = { + '/api': { + target: 'http://127.0.0.1:3000', + changeOrigin: true, + rewrite: (path) => path.replace(/^\/api/, ''), + }, + '/mock': { + target: 'http://127.0.0.1:8848', + changeOrigin: true, + rewrite: (path) => path.replace(/^\/mock/, ''), + }, +}; + +export default mergeConfig(baseConfig, { + server: { + proxy: { + ...proxyConfig, + }, + }, +}); diff --git a/packages/toolkits/pro/template/tinyvue2/config/vite.config.prod.ts b/packages/toolkits/pro/template/tinyvue2/config/vite.config.prod.ts new file mode 100644 index 00000000..7a882c51 --- /dev/null +++ b/packages/toolkits/pro/template/tinyvue2/config/vite.config.prod.ts @@ -0,0 +1,18 @@ +import { mergeConfig } from 'vite'; +import baseConfig from './vite.config.base'; + +export default mergeConfig( + { + build: { + rollupConfig: { + output: { + manualChunks: { + vue: ['vue', 'vue-router', 'pinia', '@vueuse/core', 'vue-i18n'], + }, + }, + }, + chunkSizeWarningLimit: 2000, + }, + }, + baseConfig +); diff --git a/packages/toolkits/pro/template/tinyvue2/package.json b/packages/toolkits/pro/template/tinyvue2/package.json index 472a1f4e..3f8148ec 100644 --- a/packages/toolkits/pro/template/tinyvue2/package.json +++ b/packages/toolkits/pro/template/tinyvue2/package.json @@ -2,13 +2,17 @@ "name": "tinypro-frontend", "version": "0.0.0", "scripts": { - "dev": "vite", - "build": "run-p type-check build-only", + "dev": "vite --config ./config/vite.config.dev.ts --port 3031", + "build": "run-p build-only", "preview": "vite preview --port 4173", - "build-only": "vite build", + "build-only": "vite build --config ./config/vite.config.prod.ts", "type-check": "vue-tsc --noEmit", "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore", - "mock": "tsx ./src/mock/index.ts" + "mock": "tsx ./src/mock/index.ts", + "dev:wp": "webpack-dev-server --progress --config webpack.config.js", + "build:wp": "webpack --progress --config webpack.config.js", + "dev:rp": "rspack serve", + "build:rp": "rspack build" }, "dependencies": { "@gaonengwww/mock-server": "^1.0.5", @@ -29,26 +33,41 @@ "vue-router": "^3.5.4" }, "devDependencies": { + "@rspack/cli": "^0.7.5", + "@rspack/core": "^0.7.5", "@rushstack/eslint-patch": "^1.1.0", - "@types/node": "^16.11.45", + "@types/node": "^16.18.105", "@vitejs/plugin-legacy": "^2.0.0", "@vitejs/plugin-vue2": "^1.1.2", "@vue/eslint-config-prettier": "^7.0.0", "@vue/eslint-config-typescript": "^11.0.0", "@vue/tsconfig": "^0.1.3", + "css-loader": "^7.1.2", + "dotenv": "^16.4.5", "esbuild": "^0.23.0", "eslint": "^8.5.0", "eslint-plugin-vue": "^9.0.0", + "html-webpack-plugin": "^5.6.0", + "import-meta-loader": "^1.1.0", "less": "^4.2.0", + "less-loader": "^12.2.0", "mockjs": "^1.1.0", "npm-run-all": "^4.1.5", "prettier": "^2.5.1", + "style-loader": "^4.0.0", + "style-resources-loader": "^1.5.0", "terser": "^5.14.2", + "ts-loader": "^9.5.1", "tsx": "^4.17.0", "typescript": "~4.7.4", "vite": "^3.0.2", "vite-plugin-mock": "^3.0.2", "vue-i18n-composable": "^2.0.0", - "vue-tsc": "^0.38.8" + "vue-loader": "^15.10.0", + "vue-style-loader": "^4.1.3", + "vue-tsc": "^0.38.8", + "webpack": "~5.65.0", + "webpack-cli": "^5.1.4", + "webpack-dev-server": "~4.7.1" } } diff --git a/packages/toolkits/pro/template/tinyvue2/rspack.config.js b/packages/toolkits/pro/template/tinyvue2/rspack.config.js new file mode 100644 index 00000000..69ac5f6a --- /dev/null +++ b/packages/toolkits/pro/template/tinyvue2/rspack.config.js @@ -0,0 +1,163 @@ +const { resolve } = require('path'); +const { VueLoaderPlugin } = require('vue-loader'); +const HtmlWebpackPlugin = require('html-webpack-plugin'); +const rspack = require('@rspack/core'); +const { configDotenv, parse } = require('dotenv'); +const { default: importMetaLoader } = require('import-meta-loader'); +const path = require('path'); +configDotenv({ + path: './.env', +}); + +/** @type {import('@rspack/cli').Configuration} */ +const config = { + context: __dirname, + entry: { + main: './src/main.ts', + }, + output: { + path: resolve(__dirname, 'dist'), // 打包后的文件输出的目录 + filename: `js/[name]_[chunkhash:8].js`, // 设置打包后的 js 文件名,如果在文件名前增加文件路径,会将打包后的 js 文件放在指定的文件夹下 + publicPath: '/', + }, + experiments: { + css: true, + }, + plugins: [ + new VueLoaderPlugin(), + new rspack.HtmlRspackPlugin({ + template: './index.html', + }), + new rspack.DefinePlugin({ + __VUE_OPTIONS_API__: JSON.stringify(true), + __VUE_PROD_DEVTOOLS__: JSON.stringify(false), + 'import.meta.env.VITE_CONTEXT': '"/vue-pro/"', + 'import.meta.env.VITE_BASE_API': '"/api"', + 'import.meta.env.VITE_SERVER_HOST': '"http://127.0.0.1:3000"', + 'import.meta.env.VITE_MOCK_HOST': '"http://127.0.0.1:8848"', + 'import.meta.env.VITE_USE_MOCK': 'false', + 'import.meta.env.VITE_MOCK_IGNORE': + '"/api/user/userInfo,/api/user/login,/api/user/register,/api/employee/getEmployee"', + 'import.meta.env.VITE_MOCK_SERVER_HOST': '"/mock"', + BUILD_TOOLS: "'RSPACK'", + }), + ], + devServer: { + historyApiFallback: true, + proxy: [ + { + context: [process.env.VITE_BASE_API], + target: process.env.VITE_SERVER_HOST, + changeOrigin: true, + pathRewrite: { + '^/api': '', + }, + }, + { + context: [process.env.VITE_MOCK_SERVER_HOST], + target: process.env.VITE_MOCK_HOST, + changeOrigin: true, + pathRewrite: { + '^/mock': '', + }, + }, + ], + }, + module: { + rules: [ + { + test: /\.vue$/, + loader: 'vue-loader', + options: { + experimentalInlineMatchResource: true, + }, + }, + { + test: /\.ts$/, + loader: 'builtin:swc-loader', + options: { + sourceMap: true, + jsc: { + parser: { + syntax: 'typescript', + }, + }, + }, + type: 'javascript/auto', + }, + { + test: /\.less$/, + loader: 'less-loader', + type: 'css', + }, + { + test: /\.svg$/, + type: 'asset/resource', + }, + { + test: /\.m?js/, + resolve: { + fullySpecified: false, + }, + }, + { + test: /\.less$/, + use: [ + { + loader: 'less-loader', + options: { + additionalData: `@import "${resolve( + './src/assets/style/breakpoint.less' + )}";`, + }, + }, + ], + type: 'css', + }, + { + test: /.(png|jpg|jpeg|gif|svg)$/, // 匹配图片文件 + type: 'asset', // type选择asset + parser: { + dataUrlCondition: { + maxSize: 10 * 1024, // 小于10kb转base64位 + }, + }, + generator: { + filename: 'static/images/[name].[contenthash:8][ext]', // 文件输出目录和命名 + }, + }, + { + test: /.(woff2?|eot|ttf|otf)$/, // 匹配字体图标文件 + type: 'asset', // type选择asset + parser: { + dataUrlCondition: { + maxSize: 10 * 1024, // 小于10kb转base64位 + }, + }, + generator: { + filename: 'static/fonts/[name].[contenthash:8][ext]', // 文件输出目录和命名 + }, + }, + { + test: /.(mp4|webm|ogg|mp3|wav|flac|aac)$/, // 匹配媒体文件 + type: 'asset', // type选择asset + parser: { + dataUrlCondition: { + maxSize: 10 * 1024, // 小于10kb转base64位 + }, + }, + generator: { + filename: 'static/media/[name].[contenthash:8][ext]', // 文件输出目录和命名 + }, + }, + ], + }, + resolve: { + alias: { + '@': resolve(__dirname, 'src'), + assets: resolve(__dirname, 'src/assets'), + }, + extensions: ['.ts', '.js', '.vue'], + }, +}; +module.exports = config; diff --git a/packages/toolkits/pro/template/tinyvue2/src/api/list.ts b/packages/toolkits/pro/template/tinyvue2/src/api/list.ts index fc4b2d6d..cab6eb51 100644 --- a/packages/toolkits/pro/template/tinyvue2/src/api/list.ts +++ b/packages/toolkits/pro/template/tinyvue2/src/api/list.ts @@ -7,7 +7,7 @@ export interface QueryTaskParmas { } export function queryEmployeeList(params: QueryTaskParmas) { - return axios.post('/mock/employee/getEmployee', params); + return axios.post('/mock/api/employee/getEmployee', params); } export function deleteEmployee(id: string) { return axios.delete(`/mock/employee/delete?id=${id}`); diff --git a/packages/toolkits/pro/template/tinyvue2/src/router/guard/menu.ts b/packages/toolkits/pro/template/tinyvue2/src/router/guard/menu.ts index 2da28a0c..71d50c4e 100644 --- a/packages/toolkits/pro/template/tinyvue2/src/router/guard/menu.ts +++ b/packages/toolkits/pro/template/tinyvue2/src/router/guard/menu.ts @@ -39,7 +39,7 @@ if (BUILD_TOOLS === 'VITE' || BUILD_TOOLS === 'WEBPACK') { } }); } -const toRoutes = (menus: ITreeNodeData[]) => { +export const toRoutes = (menus: ITreeNodeData[]) => { const router: any[] = []; for (let i = 0; i < menus.length; i += 1) { const menu = menus[i]; diff --git a/packages/toolkits/pro/template/tinyvue2/src/router/guard/permission.ts b/packages/toolkits/pro/template/tinyvue2/src/router/guard/permission.ts index 4b6fade3..85b8d4ae 100644 --- a/packages/toolkits/pro/template/tinyvue2/src/router/guard/permission.ts +++ b/packages/toolkits/pro/template/tinyvue2/src/router/guard/permission.ts @@ -1,3 +1,5 @@ +// import type { Router, LocationQueryRaw } from 'vue-router'; +// import NProgress from 'nprogress'; // progress bar import { getUserInfo } from '@/api/user'; import { useUserStore } from '@/stores'; import { clearToken, isLogin } from '@/utils/auth'; @@ -5,9 +7,11 @@ import { nextTick } from 'vue'; export default function setupPermissionGuard(router: any) { router.beforeEach(async (to, from, next) => { + // NProgress.start(); if (!isLogin()) { if (to.name === 'login') { next(); + // NProgress.done(); return; } next({ @@ -17,6 +21,7 @@ export default function setupPermissionGuard(router: any) { ...to.query, } as any, }); + // NProgress.done(); } else { await nextTick(); const userStore = useUserStore(); @@ -32,6 +37,7 @@ export default function setupPermissionGuard(router: any) { return; } next(); + // NProgress.done(); } }); } diff --git a/packages/toolkits/pro/template/tinyvue2/src/router/routes/index.ts b/packages/toolkits/pro/template/tinyvue2/src/router/routes/index.ts index 035975f4..040805e6 100644 --- a/packages/toolkits/pro/template/tinyvue2/src/router/routes/index.ts +++ b/packages/toolkits/pro/template/tinyvue2/src/router/routes/index.ts @@ -1,6 +1,9 @@ -import type { RouteConfig } from "vue-router"; +import type { RouteConfig } from 'vue-router'; -const modules:Record = import.meta.glob('./modules/*.ts', { eager: true }); +const modules: Record = + BUILD_TOOLS === 'RSPACK' + ? {} + : import.meta.glob('./modules/*.ts', { eager: true }); const appRoutes: RouteConfig[] = []; Object.keys(modules).forEach((key) => { diff --git a/packages/toolkits/pro/template/tinyvue2/src/views/login/components/login-mail.vue b/packages/toolkits/pro/template/tinyvue2/src/views/login/components/login-mail.vue index 2acf33ec..d6bdae6b 100644 --- a/packages/toolkits/pro/template/tinyvue2/src/views/login/components/login-mail.vue +++ b/packages/toolkits/pro/template/tinyvue2/src/views/login/components/login-mail.vue @@ -70,6 +70,7 @@ import { useI18n } from 'vue-i18n-composable'; import { useUserStore } from '@/stores/user'; import { useMenuStore } from '@/stores/modules/router'; import useLoading from '@/hooks/loading'; +import { toRoutes } from '@/router/guard/menu'; const userStore = useUserStore(); const userMenu = useMenuStore(); @@ -124,12 +125,20 @@ function handleSubmit() { status: 'success', }); const { redirect, ...othersQuery } = router.currentRoute.query; - router.push({ - name: (redirect as string) || 'Home', - query: { - ...othersQuery, - }, - }); + const menuStore = useMenuStore(); + if (!menuStore.menuList.length) { + const data = await menuStore.getMenuList(); + const routes = toRoutes(data); + routes.forEach((route) => router.addRoute('root', route)); + } + const redirectTo = + redirect && redirect.toString().toLowerCase() === 'login' + ? 'Home' + : redirect ?? 'Home'; + const route = router + .getRoutes() + .filter((route) => route.name === redirectTo)[0]; + router.replace({ path: route.path }); } catch (err) { Notify({ type: 'error', diff --git a/packages/toolkits/pro/template/tinyvue2/src/views/userManager/setting/index.vue b/packages/toolkits/pro/template/tinyvue2/src/views/userManager/setting/index.vue index c924ae86..aa0870d9 100644 --- a/packages/toolkits/pro/template/tinyvue2/src/views/userManager/setting/index.vue +++ b/packages/toolkits/pro/template/tinyvue2/src/views/userManager/setting/index.vue @@ -324,7 +324,6 @@ async function fetchData(email: string) { async function fetchRole() { const { data } = await getAllRole(); - console.log(data); state.roleData = data; } diff --git a/packages/toolkits/pro/template/tinyvue2/tsconfig.config.json b/packages/toolkits/pro/template/tinyvue2/tsconfig.config.json index f64c85e2..73a37157 100644 --- a/packages/toolkits/pro/template/tinyvue2/tsconfig.config.json +++ b/packages/toolkits/pro/template/tinyvue2/tsconfig.config.json @@ -1,6 +1,6 @@ { "extends": "@vue/tsconfig/tsconfig.node.json", - "include": ["vite.config.*", "vitest.config.*", "cypress.config.*"], + "include": ["vite.config.*", "vitest.config.*", "cypress.config.*", "config/vite.config.ts"], "compilerOptions": { "composite": true, "types": ["node"] diff --git a/packages/toolkits/pro/template/tinyvue2/webpack.config.js b/packages/toolkits/pro/template/tinyvue2/webpack.config.js new file mode 100644 index 00000000..65eb2830 --- /dev/null +++ b/packages/toolkits/pro/template/tinyvue2/webpack.config.js @@ -0,0 +1,168 @@ +const { resolve } = require('path'); +const { VueLoaderPlugin } = require('vue-loader'); +const HtmlWebpackPlugin = require('html-webpack-plugin'); +const { DefinePlugin } = require('webpack'); +const { configDotenv, parse } = require('dotenv'); +configDotenv({ + path: './.env', +}); + +/** @type {import('webpack').Configuration} */ +const config = { + mode: 'production', + entry: { + main: './src/main.ts', + }, + output: { + path: resolve(__dirname, 'dist'), // 打包后的文件输出的目录 + filename: `js/[name]_[chunkhash:8].js`, // 设置打包后的 js 文件名,如果在文件名前增加文件路径,会将打包后的 js 文件放在指定的文件夹下 + publicPath: '/', + }, + module: { + rules: [ + { + test: /\.vue$/, + loader: 'vue-loader', + }, + { + test: /\.css$/, + use: ['style-loader', 'css-loader'], + }, + { + test: /\.(ts)$/, + use: [ + { + loader: 'ts-loader', + options: { + appendTsSuffixTo: [/\.vue$/], + transpileOnly: true, + }, + }, + { + loader: 'import-meta-loader', + options: {}, + }, + ], + exclude: /node_modules/, + }, + { + test: /\.less$/, + use: [ + 'style-loader', + 'css-loader', + 'less-loader', + { + loader: 'style-resources-loader', + options: { + patterns: resolve(__dirname, 'src/assets/style/breakpoint.less'), + }, + }, + ], + }, + { + test: /\.m?js/, + resolve: { + fullySpecified: false, + }, + }, + { + test: /.(png|jpg|jpeg|gif|svg)$/, // 匹配图片文件 + type: 'asset', // type选择asset + parser: { + dataUrlCondition: { + maxSize: 10 * 1024, // 小于10kb转base64位 + }, + }, + generator: { + filename: 'static/images/[name].[contenthash:8][ext]', // 文件输出目录和命名 + }, + }, + { + test: /.(woff2?|eot|ttf|otf)$/, // 匹配字体图标文件 + type: 'asset', // type选择asset + parser: { + dataUrlCondition: { + maxSize: 10 * 1024, // 小于10kb转base64位 + }, + }, + generator: { + filename: 'static/fonts/[name].[contenthash:8][ext]', // 文件输出目录和命名 + }, + }, + { + test: /.(mp4|webm|ogg|mp3|wav|flac|aac)$/, // 匹配媒体文件 + type: 'asset', // type选择asset + parser: { + dataUrlCondition: { + maxSize: 10 * 1024, // 小于10kb转base64位 + }, + }, + generator: { + filename: 'static/media/[name].[contenthash:8][ext]', // 文件输出目录和命名 + }, + }, + ], + }, + plugins: [ + new VueLoaderPlugin(), + new HtmlWebpackPlugin({ + template: resolve(__dirname, 'index.html'), + filename: 'index.html', + chunks: ['main'], + inject: true, + minify: { + html5: true, + collapseWhitespace: true, + preserveLineBreaks: false, + minifyCSS: true, + minifyJS: true, + removeComments: false, + }, + }), + new DefinePlugin({ + 'process.env': JSON.stringify({ ...process.env }), + 'import.meta.env': '""', + 'import.meta.env.VITE_CONTEXT': `'${process.env.VITE_CONTEXT}'`, + 'import.meta.env.VITE_BASE_API': `'${process.env.VITE_BASE_API}'`, + 'import.meta.env.VITE_SERVER_HOST': `'${process.env.VITE_SERVER_HOST}'`, + 'import.meta.env.VITE_MOCK_HOST': `'${process.env.VITE_MOCK_HOST}'`, + 'import.meta.env.VITE_USE_MOCK': `${process.env.VITE_USE_MOCK}`, + 'import.meta.env.VITE_MOCK_IGNORE': `'${process.env.VITE_MOCK_IGNORE}'`, + 'import.meta.env.VITE_MOCK_SERVER_HOST': `'${process.env.VITE_MOCK_SERVER_HOST}'`, + BUILD_TOOLS: "'WEBPACK'", + }), + ], + resolve: { + alias: { + '@': resolve(__dirname, 'src'), + assets: resolve(__dirname, 'src/assets'), + }, + extensions: ['.ts', '.js', '.vue'], + }, + cache: { + type: 'filesystem', + }, + devServer: { + historyApiFallback: true, + proxy: [ + { + context: [process.env.VITE_BASE_API], + target: process.env.VITE_SERVER_HOST, + changeOrigin: true, + pathRewrite: { + '^/api': '', + }, + }, + { + context: [process.env.VITE_MOCK_SERVER_HOST], + target: process.env.VITE_MOCK_HOST, + changeOrigin: true, + pathRewrite: { + '^/mock': '', + }, + }, + ], + }, +}; + +module.exports = config;