Skip to content

Commit 2f93950

Browse files
committed
build: 优化 ui 包 types 产物、修复 gulp 打包在 win 系统的问题
1 parent 1660df5 commit 2f93950

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

build/gulpfile.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const clean = require('gulp-clean');
33
const rollup = require('rollup');
44
const bundleUI = require('./rollup.ui.config.js');
55
const bundleConfig = require('./rollup.config.js');
6+
const path = require('path');
67

78
// 清理 dist 目录
89
gulp.task('clean', function () {
@@ -11,8 +12,12 @@ gulp.task('clean', function () {
1112

1213
// 使用 Rollup 打包
1314
async function bundle(pkg) {
14-
// 错误用法:input.includes(`\\${pkg}\\`) 路径分隔符使用了Windows格式的反斜杠,这在macOS上会导致无法匹配到文件
15-
const pkgConfigs = bundleConfig.filter((c) => c.input.includes(`/${pkg}/`));
15+
// 使用 path.join 和 path.normalize 确保跨平台兼容性
16+
const normalizedPkgPath = path.normalize(`/${pkg}/`);
17+
const pkgConfigs = bundleConfig.filter((c) => {
18+
const normalizedInput = path.normalize(c.input);
19+
return normalizedInput.includes(normalizedPkgPath);
20+
});
1621

1722
if (!pkgConfigs.length) return;
1823

packages/ui/vite.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export default defineConfig({
2020
dts({
2121
// 包含的文件类型
2222
include: ['src/**/*.{vue,ts,tsx}'],
23+
exclude: ['src/__tests__/*', 'src/**/*.{test,spec,stories,demo}.{vue,ts,tsx}'],
2324
// 输出目录
2425
outDir: ['dist/types'],
2526
// 写入文件前的处理

0 commit comments

Comments
 (0)