修改路由打包配置
This commit is contained in:
parent
4bd9a3e156
commit
ac6d84d999
@ -80,7 +80,7 @@ export const constantRoutes = [
|
|||||||
}];
|
}];
|
||||||
|
|
||||||
const router = createRouter({
|
const router = createRouter({
|
||||||
history: createWebHistory(),
|
history: createWebHistory(import.meta.env.VITE_APP_ROUTER_PREFIX),
|
||||||
routes: constantRoutes,
|
routes: constantRoutes,
|
||||||
// scrollBehavior(to, from, savedPosition) {
|
// scrollBehavior(to, from, savedPosition) {
|
||||||
// if (savedPosition) {
|
// if (savedPosition) {
|
||||||
|
|||||||
@ -3,10 +3,7 @@ import path from 'path'
|
|||||||
import createVitePlugins from './vite/plugins'
|
import createVitePlugins from './vite/plugins'
|
||||||
|
|
||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default defineConfig(({
|
export default defineConfig(({ mode, command }) => {
|
||||||
mode,
|
|
||||||
command
|
|
||||||
}) => {
|
|
||||||
const env = loadEnv(mode, process.cwd())
|
const env = loadEnv(mode, process.cwd())
|
||||||
return {
|
return {
|
||||||
plugins: createVitePlugins(env, command === 'build'),
|
plugins: createVitePlugins(env, command === 'build'),
|
||||||
@ -21,6 +18,7 @@ export default defineConfig(({
|
|||||||
// https://cn.vitejs.dev/config/#resolve-extensions
|
// https://cn.vitejs.dev/config/#resolve-extensions
|
||||||
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'],
|
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'],
|
||||||
},
|
},
|
||||||
|
base: env.VITE_APP_ROUTER_PREFIX,
|
||||||
// 打包配置
|
// 打包配置
|
||||||
build: {
|
build: {
|
||||||
sourcemap: command === 'build' ? false : true,
|
sourcemap: command === 'build' ? false : true,
|
||||||
@ -28,7 +26,6 @@ export default defineConfig(({
|
|||||||
outDir: 'dist', //指定输出目录
|
outDir: 'dist', //指定输出目录
|
||||||
assetsDir: 'assets', //指定静态资源存储目录
|
assetsDir: 'assets', //指定静态资源存储目录
|
||||||
minify: 'terser', //混淆器,terser构建后文件体积更小
|
minify: 'terser', //混淆器,terser构建后文件体积更小
|
||||||
publicDir: import.meta.env.VITE_APP_ROUTER_PREFIX
|
|
||||||
},
|
},
|
||||||
// vite 相关配置
|
// vite 相关配置
|
||||||
server: {
|
server: {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user