From 75068042a121bfa006854c0bd74432f29fc8d6c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E5=81=9A=E7=A0=81=E5=86=9C?= <599854767@qq.com> Date: Wed, 27 Apr 2022 11:35:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=89=93=E5=8C=85=E5=88=86?= =?UTF-8?q?=E7=A6=BBjs=E3=80=81css=E3=80=81vue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vite.config.js | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/vite.config.js b/vite.config.js index 28632c0..3dd3f58 100644 --- a/vite.config.js +++ b/vite.config.js @@ -15,6 +15,7 @@ export default defineConfig(({ mode, command }) => { // 设置别名 '@': path.resolve(__dirname, './src') }, + // 导入时想要省略的扩展名列表 // https://cn.vitejs.dev/config/#resolve-extensions extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'], }, @@ -24,9 +25,17 @@ export default defineConfig(({ mode, command }) => { base: env.VITE_APP_ROUTER_PREFIX, // 打包配置 build: { - sourcemap: command === 'build' ? false : true, + sourcemap: command === 'build' ? false : 'inline', outDir: 'dist', //指定输出目录 assetsDir: 'assets', //指定静态资源存储目录(相对于outDir) + // 将js、css文件分离到单独文件夹 + rollupOptions: { + output: { + chunkFileNames: "static/js/[name]-[hash].js", + entryFileNames: "static/js/[name]-[hash].js", + assetFileNames: "static/[ext]/[name]-[hash].[ext]" + } + }, }, // vite 相关配置 server: { @@ -39,12 +48,12 @@ export default defineConfig(({ mode, command }) => { target: 'http://localhost:8888', changeOrigin: true, rewrite: (path) => path.replace(/^\/dev-api/, '') - }, - '/msghub': { - target: 'http://localhost:8888', - ws: true, - rewrite: (path) => path.replace(/^\/msgHub/, '') - } + }, + '/msghub': { + target: 'http://localhost:8888', + ws: true, + rewrite: (path) => path.replace(/^\/msgHub/, '') + } }, }, }