Skip to content

Commit

Permalink
feat(projects): 引入soybean-admin-tab、去除vite-plugin-svg-icons,用unplugin…
Browse files Browse the repository at this point in the history
…-icons实现自定义svg的iconify写法、代码优化
  • Loading branch information
honghuangdc committed Mar 4, 2022
1 parent b298af1 commit a1a57a1
Show file tree
Hide file tree
Showing 93 changed files with 266 additions and 6,700 deletions.
2 changes: 1 addition & 1 deletion .env
@@ -1,4 +1,4 @@
VITE_APP_BASE_URL=/
VITE_BASE_URL=/

VITE_APP_NAME=SoybeanAdmin

Expand Down
4 changes: 2 additions & 2 deletions .env-config.ts
Expand Up @@ -13,10 +13,10 @@ type ServiceEnv = Record<
export const serviceEnv: ServiceEnv = {
test: {
env: 'test',
url: 'http://120.76.42.91:18888'
url: 'http://www.baidu.com'
},
prod: {
env: 'prod',
url: 'http://120.76.42.91:18888'
url: 'http://www.baidu.com'
}
};
1 change: 1 addition & 0 deletions .env.development
@@ -0,0 +1 @@
VITE_VISUALIZER=false
Empty file added .env.production
Empty file.
1 change: 1 addition & 0 deletions .eslintignore
Expand Up @@ -11,5 +11,6 @@ lib
/docs
.vscode
.local
components.d.ts
!.env-config.ts
package.json
24 changes: 17 additions & 7 deletions build/plugins/iconify.ts
@@ -1,11 +1,21 @@
import Icons from 'unplugin-icons/vite'; // iconify图标
import IconsResolver from 'unplugin-icons/resolver';
import Components from 'unplugin-vue-components/vite'; // 从指定目录自动导入组件
import { FileSystemIconLoader } from 'unplugin-icons/loaders';

export default [
Components({
dts: false,
resolvers: [IconsResolver({ componentPrefix: 'icon' })]
}),
Icons({ scale: 1, defaultClass: 'inline-block' })
];
export default (srcPath: string) => {
return [
Icons({
compiler: 'vue3',
customCollections: {
custom: FileSystemIconLoader(`${srcPath}/assets/svg`)
},
scale: 1,
defaultClass: 'inline-block'
}),
Components({
dts: false,
resolvers: [IconsResolver({ customCollections: ['custom'], componentPrefix: 'icon' })]
})
];
};
17 changes: 13 additions & 4 deletions build/plugins/index.ts
Expand Up @@ -5,12 +5,21 @@ import iconify from './iconify';
import windicss from './windicss';
import mock from './mock';
import visualizer from './visualizer';
import svg from './svg';

export function setupVitePlugins(configEnv: ConfigEnv): (PluginOption | PluginOption[])[] {
const plugins = [vue, html(configEnv), ...iconify, windicss, mock, svg];
/**
* vite插件
* @param configEnv - 环境
* @param srcPath - src路径
* @param viteEnv - 环境变量配置
*/
export function setupVitePlugins(
configEnv: ConfigEnv,
srcPath: string,
viteEnv: ImportMetaEnv
): (PluginOption | PluginOption[])[] {
const plugins = [vue, html(configEnv), ...iconify(srcPath), windicss, mock];

if (configEnv.command === 'build') {
if (configEnv.command === 'build' && viteEnv.VITE_VISUALIZER === 'true') {
plugins.push(visualizer);
}

Expand Down
7 changes: 0 additions & 7 deletions build/plugins/svg.ts

This file was deleted.

8 changes: 4 additions & 4 deletions package.json
Expand Up @@ -7,7 +7,7 @@
"typecheck": "vue-tsc",
"build": "npm run typecheck && cross-env VITE_HTTP_ENV=prod vite build",
"build:test": "npm run typecheck && cross-env VITE_HTTP_ENV=test vite build",
"build:vercel": "cross-env VITE_HTTP_ENV=prod VITE_IS_VERCEL=1 vite build",
"build:vercel": "cross-env VITE_HASH_ROUTE=true vite build",
"preview": "vite preview --port 5050",
"release": "standard-version",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md",
Expand Down Expand Up @@ -39,7 +39,8 @@
"print-js": "^1.6.0",
"qs": "^6.10.3",
"soybean-admin-layout": "^1.0.4",
"swiper": "^8.0.6",
"soybean-admin-tab": "^1.2.3",
"swiper": "^8.0.7",
"ua-parser-js": "^1.0.2",
"vditor": "^3.8.12",
"vue": "^3.2.31",
Expand All @@ -51,7 +52,7 @@
"@amap/amap-jsapi-types": "^0.0.8",
"@commitlint/cli": "^16.2.1",
"@commitlint/config-conventional": "^16.2.1",
"@iconify/json": "^2.1.10",
"@iconify/json": "^2.1.11",
"@iconify/vue": "^3.1.4",
"@types/bmapgl": "^0.0.5",
"@types/crypto-js": "^4.1.1",
Expand Down Expand Up @@ -87,7 +88,6 @@
"vite": "2.8.6",
"vite-plugin-html": "^3.1.0",
"vite-plugin-mock": "^2.9.6",
"vite-plugin-svg-icons": "^2.0.1",
"vite-plugin-windicss": "^1.8.2",
"vue-tsc": "^0.32.1",
"vueuc": "^0.4.27",
Expand Down

0 comments on commit a1a57a1

Please sign in to comment.