Skip to content

Commit

Permalink
fix: 修复打包报错
Browse files Browse the repository at this point in the history
  • Loading branch information
shunyue1320 committed Dec 26, 2023
1 parent 175fe91 commit 080b680
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 23 deletions.
17 changes: 2 additions & 15 deletions .github/workflows/deploy-site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: [main] # 触发当前事件分支
paths:
- 'packages/vant/**' # 触发当前事件路径
- 'packages/**' # 触发当前事件路径

workflow_dispatch:

Expand Down Expand Up @@ -41,24 +41,11 @@ jobs:
run: npm run build:site

# 部署站点
- name: Deploy for Gitee 🚀
- name: Deploy for GitHub 🚀
uses: JamesIves/github-pages-deploy-action@v4.4.1
with:
branch: gh-pages # 部署到 gh-pages 分支
folder: packages/vant/site-dist # 部署的文件夹
# 启用 single-commit 以减少回购规模
single-commit: true # 单次提交
clean: true # 清理

# 部署站点
- name: Deploy for GitHub 🚀
uses: JamesIves/github-pages-deploy-action@v4.4.1
with:
branch: main # 部署到 main 分支
folder: packages/vant/site-dist # 部署的文件夹
token: ${{ secrets.VANT_UI_TOKEN }} # GitHub Token
repository-name: vant-ui/vant-ui.github.io # 仓库名称
target-folder: vant # 部署的文件夹
# 启用 single-commit 以减少回购规模
single-commit: true # 单次提交
clean: true # 清理
40 changes: 40 additions & 0 deletions packages/vant-use/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const { build, context } = require('esbuild');

async function bundle(format) {
const ext = format === 'esm' ? '.mjs' : '.js';
const outfile = `dist/index.${format}${ext}`;
const finish = () => console.log('Build finished:', outfile);

const options = {
format,
bundle: true,
target: ['chrome53'],
outfile,
// preserve Chinese character
charset: 'utf8',
external: ['vue', 'vant'],
entryPoints: ['./src/index.ts'],
};

if (process.argv.includes('-w')) {
const loggerPlugin = {
name: 'loggerPlugin',
setup(build) {
build.onEnd(finish);
},
};

const ctx = await context({
...options,
plugins: [loggerPlugin],
});

await ctx.watch();
} else {
await build(options);
finish();
}
}

bundle('esm');
bundle('cjs');
8 changes: 1 addition & 7 deletions packages/vant-use/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,7 @@
"access": "public",
"registry": "https://registry.npmjs.org/"
},
"repository": {
"type": "git",
"url": "https://github.com/vant-ui/vant.git",
"directory": "packages/vant-use"
},
"bugs": "https://github.com/vant-ui/vant/issues",
"author": "chenjiahan",
"author": "shunyue1320",
"license": "MIT",
"devDependencies": {
"esbuild": "^0.18.11",
Expand Down
2 changes: 1 addition & 1 deletion packages/vant-use/src/useEventListener/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function useEventListener(
let attached: boolean; // 是否已经添加了事件侦听器

/** 添加监听 */
const add = (target: TargetRef) => {
const add = (target?: TargetRef) => {
if (cleaned) {
return;
}
Expand Down

0 comments on commit 080b680

Please sign in to comment.