@playcraft/build 0.1.98 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -131,13 +131,15 @@ async function applyExternFiles(outDir, externFiles) {
131
131
  const folderName = externFiles.folderName?.trim() || `playcraft-assets-${crypto.randomUUID()}`;
132
132
  const externalPrefix = externFiles.externalUrlPrefix?.trim().replace(/\/+$/g, '');
133
133
  const assetPrefix = externalPrefix ? `${externalPrefix}/${folderName}/` : `${folderName}/`;
134
+ // 资源已全部内联到 index.html 时没有文件需要外置,不创建资源文件夹,也不改写路径,
135
+ // 否则 ZIP 中会留下一个没有引用的空目录。
136
+ const entries = (await fs.readdir(outDir, { withFileTypes: true })).filter((entry) => entry.name !== 'index.html' && entry.name !== folderName);
137
+ if (entries.length === 0) {
138
+ return;
139
+ }
134
140
  const folderPath = path.join(outDir, folderName);
135
141
  await fs.mkdir(folderPath, { recursive: true });
136
- const entries = await fs.readdir(outDir, { withFileTypes: true });
137
142
  for (const entry of entries) {
138
- if (entry.name === 'index.html' || entry.name === folderName) {
139
- continue;
140
- }
141
143
  const srcPath = path.join(outDir, entry.name);
142
144
  const destPath = path.join(folderPath, entry.name);
143
145
  await fs.rename(srcPath, destPath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playcraft/build",
3
- "version": "0.1.98",
3
+ "version": "0.2.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",