Skip to content

Commit

Permalink
build(projects): add vite plugin @soybeanjs/router-page
Browse files Browse the repository at this point in the history
  • Loading branch information
honghuangdc committed Nov 7, 2022
1 parent 288d586 commit 40c1e13
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 1 deletion.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
!.env-config.ts
components.d.ts
router-page.d.ts
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ stats.html
*.sw?

/src/typings/components.d.ts
/src/typings/router-page.d.ts
package-lock.json
yarn.lock
13 changes: 12 additions & 1 deletion build/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,24 @@ import unplugin from './unplugin';
import mock from './mock';
import visualizer from './visualizer';
import compress from './compress';
import soybeanjs from './soybeanjs';

/**
* vite插件
* @param viteEnv - 环境变量配置
*/
export function setupVitePlugins(viteEnv: ImportMetaEnv): (PluginOption | PluginOption[])[] {
const plugins = [vue(), vueJsx(), VitePWA(), html(viteEnv), ...unplugin(viteEnv), unocss(), mock, progress()];
const plugins = [
vue(),
vueJsx(),
VitePWA(),
html(viteEnv),
...unplugin(viteEnv),
unocss(),
mock,
progress(),
soybeanjs()
];

if (viteEnv.VITE_VISUALIZER === 'Y') {
plugins.push(visualizer as PluginOption);
Expand Down
18 changes: 18 additions & 0 deletions build/plugins/soybeanjs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import routerPage from '@soybeanjs/router-page';

export default function createSoybeanjsPlugin() {
return routerPage({
pagesFormatter: names => {
/** 系统的内置路由,该文件夹名称不作为RouteKey */
const SYSTEM_VIEW = 'system-view';

const result = names
.filter(name => name !== SYSTEM_VIEW)
.map(name => {
return name.replace(`${SYSTEM_VIEW}_`, '');
});

return result;
}
});
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
"@iconify/json": "^2.1.133",
"@iconify/vue": "^4.0.0",
"@soybeanjs/cli": "^0.1.2",
"@soybeanjs/router-page": "0.2.0",
"@tauri-apps/cli": "^1.1.1",
"@types/bmapgl": "^0.0.5",
"@types/crypto-js": "^4.1.1",
Expand Down
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 40c1e13

Please sign in to comment.