Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add VITE_ELEGANT_ROUTER env configure for Elegant Router generate #512

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,6 @@ VITE_SOURCE_MAP=N

# Used to differentiate storage across different domains
VITE_STORAGE_PREFIX=SOY_

# ElegantRouter generate
VITE_ELEGANT_ROUTER=Y
2 changes: 1 addition & 1 deletion build/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function setupVitePlugins(viteEnv: Env.ImportMeta, buildTime: string) {
}),
vueJsx(),
VueDevtools(),
setupElegantRouter(),
setupElegantRouter(viteEnv),
setupUnocss(viteEnv),
...setupUnplugin(viteEnv),
progress(),
Expand Down
6 changes: 5 additions & 1 deletion build/plugins/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import type { RouteMeta } from 'vue-router';
import ElegantVueRouter from '@elegant-router/vue/vite';
import type { RouteKey } from '@elegant-router/types';

export function setupElegantRouter() {
export function setupElegantRouter(viteEnv: Env.ImportMeta) {
const { VITE_ELEGANT_ROUTER } = viteEnv;
if (VITE_ELEGANT_ROUTER === 'N') {
return false;
}
return ElegantVueRouter({
layouts: {
base: 'src/layouts/base-layout/index.vue',
Expand Down
2 changes: 2 additions & 0 deletions src/typings/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ declare namespace Env {
readonly VITE_ICONIFY_URL?: string;
/** Used to differentiate storage across different domains */
readonly VITE_STORAGE_PREFIX?: string;
/** Whether to build with ElegantVueRouter */
readonly VITE_ELEGANT_ROUTER?: CommonType.YesOrNo;
}
}

Expand Down
Loading