Skip to content

Commit

Permalink
chore: optimize auto import
Browse files Browse the repository at this point in the history
  • Loading branch information
devhaozi committed Dec 28, 2024
1 parent f7b0798 commit e583967
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 12 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,9 @@ jobs:
cache: 'pnpm'
cache-dependency-path: web/pnpm-lock.yaml
- name: Build frontend
# We need to run the dev server first to generate the auto-imports files
run: |
cp .env.production .env
cp settings/proxy-config.example.ts settings/proxy-config.ts
pnpm dev &
sleep 5
kill %1
pnpm build
- name: Upload frontend
uses: actions/upload-artifact@v4
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,9 @@ jobs:
cache-dependency-path: web/pnpm-lock.yaml
- name: Build frontend
working-directory: web
# We need to run the dev server first to generate the auto-imports files
run: |
cp .env.production .env
cp settings/proxy-config.example.ts settings/proxy-config.ts
pnpm dev &
sleep 5
kill %1
pnpm build
- name: Set environment variables
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ jobs:
cache: 'pnpm'
cache-dependency-path: web/pnpm-lock.yaml
- name: Run pnpm lint
run: pnpm lint
run: pnpm lint
10 changes: 10 additions & 0 deletions web/gen-auto-import.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import unplugin from './build/plugins/unplugin'

function genAutoImport() {
const autoImport = unplugin[0]
autoImport.buildStart.call({
root: process.cwd()
})
}

genAutoImport()
9 changes: 6 additions & 3 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
},
"scripts": {
"dev": "vite",
"build": "run-p type-check build-only copy",
"build": "run-p gen-auto-import type-check build-only copy",
"preview": "vite preview",
"build-only": "vite build",
"type-check": "vue-tsc --build --force",
"lint": "eslint . --fix",
"lint": "run-p gen-auto-import lint-only",
"lint-only": "eslint . --fix",
"format": "prettier --write src/",
"copy": "cpx \"dist/**/*\" \"../internal/embed/frontend\" -C"
"copy": "cpx \"dist/**/*\" \"../internal/embed/frontend\" -C",
"gen-auto-import": "tsx gen-auto-import.ts"
},
"dependencies": {
"@eslint/eslintrc": "^3.2.0",
Expand Down Expand Up @@ -76,6 +78,7 @@
"prettier": "^3.3.3",
"prettier-plugin-organize-imports": "^4.1.0",
"sass": "^1.81.0",
"tsx": "^4.19.2",
"typescript": "5.7.2",
"unocss": "^0.65.0",
"unplugin-auto-import": "^0.19.0",
Expand Down
19 changes: 19 additions & 0 deletions web/pnpm-lock.yaml

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

0 comments on commit e583967

Please sign in to comment.