balm-core 6.0.0-alpha.1 → 6.0.0-alpha.3

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.
Files changed (55) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/index.cjs +578 -206
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +41 -3
  5. package/dist/index.d.ts +41 -3
  6. package/dist/index.js +567 -196
  7. package/dist/index.js.map +1 -1
  8. package/package.json +38 -1
  9. package/src/balm.ts +0 -108
  10. package/src/bundler/esbuild.ts +0 -47
  11. package/src/bundler/index.ts +0 -3
  12. package/src/bundler/rollup.ts +0 -45
  13. package/src/bundler/webpack.ts +0 -124
  14. package/src/config/constants.ts +0 -12
  15. package/src/config/defaults.ts +0 -209
  16. package/src/config/index.ts +0 -112
  17. package/src/hooks/index.ts +0 -224
  18. package/src/index.ts +0 -16
  19. package/src/pipeline/file.ts +0 -69
  20. package/src/pipeline/index.ts +0 -10
  21. package/src/pipeline/pipeline.ts +0 -135
  22. package/src/pipeline/transforms/cache.ts +0 -146
  23. package/src/pipeline/transforms/htmlmin.ts +0 -18
  24. package/src/pipeline/transforms/less.ts +0 -75
  25. package/src/pipeline/transforms/postcss.ts +0 -43
  26. package/src/pipeline/transforms/rename.ts +0 -37
  27. package/src/pipeline/transforms/replace.ts +0 -30
  28. package/src/pipeline/transforms/sass.ts +0 -106
  29. package/src/pipeline/transforms/terser.ts +0 -20
  30. package/src/runner/dag.ts +0 -77
  31. package/src/runner/task.ts +0 -38
  32. package/src/shims.d.ts +0 -5
  33. package/src/tasks/cache.ts +0 -72
  34. package/src/tasks/clean.ts +0 -21
  35. package/src/tasks/copy.ts +0 -36
  36. package/src/tasks/ftp.ts +0 -90
  37. package/src/tasks/html.ts +0 -232
  38. package/src/tasks/index.ts +0 -14
  39. package/src/tasks/publish.ts +0 -71
  40. package/src/tasks/pwa.ts +0 -99
  41. package/src/tasks/remove.ts +0 -24
  42. package/src/tasks/replace.ts +0 -34
  43. package/src/tasks/script.ts +0 -28
  44. package/src/tasks/server.ts +0 -183
  45. package/src/tasks/static.ts +0 -104
  46. package/src/tasks/style.ts +0 -57
  47. package/src/tasks/zip.ts +0 -65
  48. package/src/types/index.ts +0 -202
  49. package/src/utilities/file.ts +0 -120
  50. package/src/utilities/logger.ts +0 -63
  51. package/src/utilities/utils.ts +0 -46
  52. package/src/utilities/workspace.ts +0 -38
  53. package/src/watcher/index.ts +0 -100
  54. package/tsconfig.json +0 -8
  55. package/tsup.config.ts +0 -12
package/dist/index.cjs CHANGED
@@ -77,6 +77,7 @@ __export(index_exports, {
77
77
  localWorkspace: () => localWorkspace,
78
78
  logger: () => logger,
79
79
  resolveConfig: () => resolveConfig,
80
+ resolveDefaultEntry: () => resolveDefaultEntry,
80
81
  runEsbuild: () => runEsbuild,
81
82
  runRollup: () => runRollup,
82
83
  runWebpack: () => runWebpack,
@@ -92,7 +93,7 @@ __export(index_exports, {
92
93
  });
93
94
  module.exports = __toCommonJS(index_exports);
94
95
 
95
- // ../../node_modules/.pnpm/tsup@8.5.1_postcss@8.5.26_typescript@5.9.3_yaml@2.9.0/node_modules/tsup/assets/cjs_shims.js
96
+ // ../../node_modules/.pnpm/tsup@8.5.1_jiti@2.7.0_postcss@8.5.26_typescript@5.9.3_yaml@2.9.0/node_modules/tsup/assets/cjs_shims.js
96
97
  var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
97
98
  var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
98
99
 
@@ -181,6 +182,19 @@ function createDefaultConfig(workspace = process.cwd()) {
181
182
  js: true,
182
183
  url: true
183
184
  },
185
+ includeJsResource: [],
186
+ excludeUrlResource: [],
187
+ useEsModule: true,
188
+ urlLoaderOptions: {},
189
+ babelLoaderOptions: {},
190
+ htmlLoaderOptions: {},
191
+ postcssLoaderOptions: {},
192
+ sourceMap: false,
193
+ stats: void 0,
194
+ optimization: {},
195
+ extractAllVendors: false,
196
+ vendorName: "vendor",
197
+ extractCss: false,
184
198
  options: {},
185
199
  esbuildOptions: {},
186
200
  rollupOptions: {},
@@ -201,7 +215,8 @@ function createDefaultConfig(workspace = process.cwd()) {
201
215
  removeEmptyAttributes: true,
202
216
  removeScriptTypeAttributes: true,
203
217
  removeStyleLinkTypeAttributes: true
204
- }
218
+ },
219
+ analytics: void 0
205
220
  };
206
221
  const assets = {
207
222
  root: "assets",
@@ -218,6 +233,10 @@ function createDefaultConfig(workspace = process.cwd()) {
218
233
  includes: [],
219
234
  excludes: []
220
235
  };
236
+ const extras = {
237
+ includes: [],
238
+ excludes: []
239
+ };
221
240
  const server = {
222
241
  host: null,
223
242
  port: 3e3,
@@ -225,6 +244,7 @@ function createDefaultConfig(workspace = process.cwd()) {
225
244
  proxy: false,
226
245
  proxyOptions: false,
227
246
  historyOptions: false,
247
+ serveStatic: [],
228
248
  useHMR: false,
229
249
  options: {}
230
250
  };
@@ -233,8 +253,9 @@ function createDefaultConfig(workspace = process.cwd()) {
233
253
  mode: "generateSW",
234
254
  version: "",
235
255
  manifest: "manifest.json",
256
+ workboxSw: "node_modules/workbox-sw/build/workbox-sw.js",
236
257
  swSrcFilename: "service-worker.js",
237
- swDestFilename: "service-worker.js",
258
+ swDestFilename: "sw.js",
238
259
  options: {}
239
260
  };
240
261
  const ftp = {
@@ -289,6 +310,7 @@ function createDefaultConfig(workspace = process.cwd()) {
289
310
  scripts,
290
311
  html,
291
312
  assets,
313
+ extras,
292
314
  server,
293
315
  pwa,
294
316
  ftp,
@@ -317,13 +339,18 @@ function isFunction(val) {
317
339
  function isBoolean(val) {
318
340
  return typeof val === "boolean";
319
341
  }
342
+ function isPlainObject(val) {
343
+ if (val === null || typeof val !== "object") return false;
344
+ const proto = Object.getPrototypeOf(val);
345
+ return proto === Object.prototype || proto === null;
346
+ }
320
347
  function deepMerge(target, ...sources) {
321
348
  if (!sources.length) return target;
322
349
  const source = sources.shift();
323
- if (isObject(target) && isObject(source)) {
350
+ if (isPlainObject(target) && isPlainObject(source)) {
324
351
  for (const key in source) {
325
- if (isObject(source[key])) {
326
- if (!target[key]) Object.assign(target, { [key]: {} });
352
+ if (isPlainObject(source[key])) {
353
+ if (!isPlainObject(target[key])) Object.assign(target, { [key]: {} });
327
354
  deepMerge(target[key], source[key]);
328
355
  } else if (isArray(source[key])) {
329
356
  target[key] = [...source[key]];
@@ -697,6 +724,25 @@ var FileSystem = class {
697
724
  }
698
725
  };
699
726
  var file = new FileSystem();
727
+ function resolveDefaultEntry(jsDir) {
728
+ const candidates = [
729
+ "main.js",
730
+ "main.ts",
731
+ "index.js",
732
+ "index.ts",
733
+ "main.jsx",
734
+ "main.tsx",
735
+ "index.jsx",
736
+ "index.tsx"
737
+ ];
738
+ for (const c of candidates) {
739
+ const full = import_node_path4.default.join(jsDir, c);
740
+ if ((0, import_node_fs.existsSync)(full)) {
741
+ return full;
742
+ }
743
+ }
744
+ return import_node_path4.default.join(jsDir, "main.js");
745
+ }
700
746
 
701
747
  // src/tasks/clean.ts
702
748
  var CleanTask = class extends BaseTask {
@@ -947,7 +993,7 @@ function transformSass(options = {}) {
947
993
  url: new URL(`file://${file2.path}`),
948
994
  syntax: file2.extname === ".sass" ? "indented" : "scss",
949
995
  loadPaths: searchDirs,
950
- importers: [customImporter, new sass.NodePackageImporter()],
996
+ importers: [customImporter, new sass.NodePackageImporter(file2.cwd || process.cwd())],
951
997
  style: options.style || "expanded",
952
998
  sourceMap: options.sourceMap || false
953
999
  });
@@ -1100,11 +1146,177 @@ var StyleTask = class extends BaseTask {
1100
1146
  // src/bundler/webpack.ts
1101
1147
  var import_webpack = __toESM(require("webpack"), 1);
1102
1148
  var import_node_path11 = __toESM(require("path"), 1);
1149
+ var import_node_fs3 = require("fs");
1150
+ var import_node_module = require("module");
1151
+ var import_autoprefixer2 = __toESM(require("autoprefixer"), 1);
1152
+ var import_postcss_preset_env2 = __toESM(require("postcss-preset-env"), 1);
1153
+ var coreRequire = (0, import_node_module.createRequire)(importMetaUrl);
1154
+ var BABEL_CONFIG_FILES = [
1155
+ "babel.config.js",
1156
+ "babel.config.cjs",
1157
+ "babel.config.mjs",
1158
+ "babel.config.json",
1159
+ ".babelrc",
1160
+ ".babelrc.js",
1161
+ ".babelrc.cjs",
1162
+ ".babelrc.json"
1163
+ ];
1164
+ function resolveModule(pkgName, workspace) {
1165
+ try {
1166
+ const workspaceRequire = (0, import_node_module.createRequire)(import_node_path11.default.join(workspace, "package.json"));
1167
+ return workspaceRequire.resolve(pkgName);
1168
+ } catch {
1169
+ return coreRequire.resolve(pkgName);
1170
+ }
1171
+ }
1172
+ function resolveWorkspacePaths(paths, workspace) {
1173
+ if (!paths || !paths.length) return [];
1174
+ return paths.map((p) => import_node_path11.default.isAbsolute(p) ? p : import_node_path11.default.resolve(workspace, p));
1175
+ }
1176
+ function hasBabelConfig(config) {
1177
+ if (config.scripts.babelLoaderOptions && Object.keys(config.scripts.babelLoaderOptions).length > 0) {
1178
+ return true;
1179
+ }
1180
+ for (const filename of BABEL_CONFIG_FILES) {
1181
+ if ((0, import_node_fs3.existsSync)(import_node_path11.default.join(config.workspace, filename))) {
1182
+ return true;
1183
+ }
1184
+ }
1185
+ const pkgPath = import_node_path11.default.join(config.workspace, "package.json");
1186
+ if ((0, import_node_fs3.existsSync)(pkgPath)) {
1187
+ try {
1188
+ const pkg = JSON.parse((0, import_node_fs3.readFileSync)(pkgPath, "utf-8"));
1189
+ if (pkg && pkg.babel) {
1190
+ return true;
1191
+ }
1192
+ } catch {
1193
+ }
1194
+ }
1195
+ return false;
1196
+ }
1197
+ function buildDefaultRules(config, dirs, devtool) {
1198
+ const isProd = config.env.isProd;
1199
+ const scripts = config.scripts;
1200
+ const esModule = scripts.useEsModule ?? true;
1201
+ const defaults = {
1202
+ html: true,
1203
+ css: true,
1204
+ js: true,
1205
+ url: true,
1206
+ ...scripts.defaultLoaders || {}
1207
+ };
1208
+ const rules = [];
1209
+ if (defaults.html) {
1210
+ rules.push({
1211
+ test: /\.html$/i,
1212
+ exclude: /\.vue\.html$/i,
1213
+ loader: resolveModule("html-loader", config.workspace),
1214
+ options: {
1215
+ minimize: {
1216
+ removeAttributeQuotes: false
1217
+ },
1218
+ esModule,
1219
+ ...scripts.htmlLoaderOptions || {}
1220
+ }
1221
+ });
1222
+ }
1223
+ if (defaults.css) {
1224
+ const cssSourceMap = Boolean(devtool);
1225
+ const MiniCssExtractPlugin = coreRequire("mini-css-extract-plugin");
1226
+ const styleLoader = isProd && scripts.extractCss ? {
1227
+ loader: MiniCssExtractPlugin.loader,
1228
+ options: { esModule }
1229
+ } : {
1230
+ loader: resolveModule("style-loader", config.workspace),
1231
+ options: { esModule }
1232
+ };
1233
+ const postcssPlugins = [
1234
+ ...config.styles.postcssPlugins || [],
1235
+ (0, import_autoprefixer2.default)(),
1236
+ (0, import_postcss_preset_env2.default)()
1237
+ ];
1238
+ const createCssUse = (isModule) => [
1239
+ styleLoader,
1240
+ {
1241
+ loader: resolveModule("css-loader", config.workspace),
1242
+ options: {
1243
+ importLoaders: 1,
1244
+ sourceMap: cssSourceMap,
1245
+ modules: isModule ? { auto: true } : { mode: "icss" },
1246
+ esModule
1247
+ }
1248
+ },
1249
+ {
1250
+ loader: resolveModule("postcss-loader", config.workspace),
1251
+ options: {
1252
+ postcssOptions: {
1253
+ plugins: postcssPlugins
1254
+ },
1255
+ sourceMap: cssSourceMap,
1256
+ ...scripts.postcssLoaderOptions || {}
1257
+ }
1258
+ }
1259
+ ];
1260
+ rules.push(
1261
+ {
1262
+ test: /\.css$/,
1263
+ exclude: /\.module\.css$/,
1264
+ use: createCssUse(false),
1265
+ sideEffects: true
1266
+ },
1267
+ {
1268
+ test: /\.module\.css$/,
1269
+ use: createCssUse(true)
1270
+ }
1271
+ );
1272
+ }
1273
+ if (defaults.js && hasBabelConfig(config)) {
1274
+ const jsIncludes = [
1275
+ config.src.js,
1276
+ ...resolveWorkspacePaths(scripts.includeJsResource, config.workspace)
1277
+ ];
1278
+ rules.push({
1279
+ test: /\.(js|mjs|jsx|ts|tsx)$/,
1280
+ include: jsIncludes,
1281
+ loader: resolveModule("babel-loader", config.workspace),
1282
+ options: {
1283
+ cwd: config.workspace,
1284
+ ...scripts.babelLoaderOptions || {}
1285
+ }
1286
+ });
1287
+ }
1288
+ if (defaults.url) {
1289
+ const rawLimit = scripts.urlLoaderOptions?.limit ?? (process.env.IMAGE_INLINE_SIZE_LIMIT ? parseInt(process.env.IMAGE_INLINE_SIZE_LIMIT, 10) : 1e4);
1290
+ const maxSize = typeof rawLimit === "number" && rawLimit > 0 ? rawLimit : 0;
1291
+ const excludeUrl = resolveWorkspacePaths(scripts.excludeUrlResource, config.workspace);
1292
+ const createAssetRule = (test, targetDir, exclude) => ({
1293
+ test,
1294
+ ...exclude && exclude.length ? { exclude } : {},
1295
+ type: maxSize > 0 ? "asset" : "asset/resource",
1296
+ ...maxSize > 0 ? {
1297
+ parser: {
1298
+ dataUrlCondition: {
1299
+ maxSize
1300
+ }
1301
+ }
1302
+ } : {},
1303
+ generator: {
1304
+ filename: `${targetDir}/[name].[hash:8][ext]`
1305
+ }
1306
+ });
1307
+ rules.push(
1308
+ createAssetRule(/\.(bmp|gif|jpe?g|png|svg|webp)(\?.*)?$/i, dirs.imgDir, excludeUrl),
1309
+ createAssetRule(/\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/i, dirs.mediaDir),
1310
+ createAssetRule(/\.(woff2?|eot|ttf|otf)(\?.*)?$/i, dirs.fontDir)
1311
+ );
1312
+ }
1313
+ return rules;
1314
+ }
1103
1315
  async function runWebpack(config, customOptions = {}) {
1104
1316
  const isProd = config.env.isProd;
1105
1317
  let entry = customOptions.entry || config.scripts.entry;
1106
1318
  if (!entry) {
1107
- entry = import_node_path11.default.join(config.src.js, "main.js");
1319
+ entry = resolveDefaultEntry(config.src.js);
1108
1320
  }
1109
1321
  const rawOutputPath = customOptions.output?.path;
1110
1322
  const isCustomOutput = Boolean(rawOutputPath);
@@ -1112,6 +1324,45 @@ async function runWebpack(config, customOptions = {}) {
1112
1324
  const jsDir = isCustomOutput ? "" : isProd ? config.paths.target.js : config.paths.tmp.js;
1113
1325
  const imgDir = isProd ? config.paths.target.img : config.paths.tmp.img;
1114
1326
  const fontDir = isProd ? config.paths.target.font : config.paths.tmp.font;
1327
+ const mediaDir = isProd ? config.paths.target.media : config.paths.tmp.media;
1328
+ const devtool = config.scripts.sourceMap ? config.scripts.sourceMap === true ? isProd ? "source-map" : "eval-cheap-module-source-map" : config.scripts.sourceMap : isProd ? false : "eval-cheap-module-source-map";
1329
+ const libraryConfig = config.scripts.library ? typeof config.scripts.library === "string" && config.scripts.libraryTarget && config.scripts.libraryTarget !== "var" ? { name: config.scripts.library, type: config.scripts.libraryTarget } : config.scripts.library : void 0;
1330
+ const defaultRules = buildDefaultRules(config, { imgDir, fontDir, mediaDir }, devtool);
1331
+ const plugins = [...config.scripts.plugins || []];
1332
+ if (isProd && config.scripts.extractCss) {
1333
+ const MiniCssExtractPlugin = coreRequire("mini-css-extract-plugin");
1334
+ const cssDir = config.paths.target.css;
1335
+ const cssFilename = config.assets.cache ? `${cssDir}/async/[name].[contenthash:8].css` : `${cssDir}/async/[name].css`;
1336
+ plugins.push(
1337
+ new MiniCssExtractPlugin({
1338
+ filename: cssFilename,
1339
+ chunkFilename: cssFilename
1340
+ })
1341
+ );
1342
+ }
1343
+ const vendorName = config.scripts.vendorName || "vendor";
1344
+ const defaultOptimization = {
1345
+ minimize: isProd || config.scripts.minify
1346
+ };
1347
+ if (config.scripts.extractAllVendors) {
1348
+ const vendorFilename = isCustomOutput ? `${vendorName}.js` : isProd && config.assets.cache ? `${jsDir}/${vendorName}.[contenthash:8].js` : `${jsDir}/${vendorName}.js`;
1349
+ defaultOptimization.splitChunks = {
1350
+ cacheGroups: {
1351
+ vendors: {
1352
+ name: vendorName,
1353
+ chunks: "initial",
1354
+ test: /[\\/](node_modules|bower_components)[\\/]/,
1355
+ filename: vendorFilename
1356
+ }
1357
+ }
1358
+ };
1359
+ }
1360
+ const optimization = deepMerge(
1361
+ {},
1362
+ defaultOptimization,
1363
+ config.scripts.optimization || {}
1364
+ );
1365
+ const externals = config.scripts.externals && (typeof config.scripts.externals !== "string" || config.scripts.externals.length > 0) ? config.scripts.externals : void 0;
1115
1366
  const defaultWebpackConfig = {
1116
1367
  mode: isProd ? "production" : "development",
1117
1368
  context: config.workspace,
@@ -1121,14 +1372,13 @@ async function runWebpack(config, customOptions = {}) {
1121
1372
  filename: isCustomOutput ? "[name].js" : isProd && config.assets.cache ? `${jsDir}/[name].[contenthash:8].js` : `${jsDir}/[name].js`,
1122
1373
  chunkFilename: isCustomOutput ? "chunk/[name].js" : isProd && config.assets.cache ? `${jsDir}/chunk/[name].[chunkhash:8].js` : `${jsDir}/chunk/[name].js`,
1123
1374
  publicPath: config.assets.virtualDir ? `/${config.assets.virtualDir}/` : "/",
1124
- ...config.scripts.library ? { library: config.scripts.library } : {}
1375
+ ...libraryConfig ? { library: libraryConfig } : {}
1125
1376
  },
1126
1377
  target: config.scripts.target || "web",
1127
- externals: config.scripts.externals,
1128
- plugins: [
1129
- ...config.scripts.plugins || []
1130
- ],
1378
+ ...externals !== void 0 ? { externals } : {},
1379
+ plugins,
1131
1380
  resolve: {
1381
+ modules: ["node_modules", config.src.base],
1132
1382
  extensions: [
1133
1383
  ".wasm",
1134
1384
  ".mjs",
@@ -1146,28 +1396,11 @@ async function runWebpack(config, customOptions = {}) {
1146
1396
  }
1147
1397
  },
1148
1398
  module: {
1149
- rules: [
1150
- ...config.scripts.loaders || [],
1151
- {
1152
- test: /\.(png|jpe?g|gif|svg|webp)$/i,
1153
- type: "asset/resource",
1154
- generator: {
1155
- filename: `${imgDir}/[name].[hash:8][ext]`
1156
- }
1157
- },
1158
- {
1159
- test: /\.(woff2?|eot|ttf|otf)$/i,
1160
- type: "asset/resource",
1161
- generator: {
1162
- filename: `${fontDir}/[name].[hash:8][ext]`
1163
- }
1164
- }
1165
- ]
1399
+ rules: [...defaultRules, ...config.scripts.loaders || []]
1166
1400
  },
1167
- optimization: {
1168
- minimize: isProd || config.scripts.minify
1169
- },
1170
- devtool: isProd ? false : "eval-cheap-module-source-map"
1401
+ optimization,
1402
+ ...config.scripts.stats !== void 0 ? { stats: config.scripts.stats } : {},
1403
+ devtool
1171
1404
  };
1172
1405
  const webpackConfig = {
1173
1406
  ...defaultWebpackConfig,
@@ -1185,26 +1418,32 @@ async function runWebpack(config, customOptions = {}) {
1185
1418
  compiler.run((err, stats) => {
1186
1419
  if (err) {
1187
1420
  logger.error("webpack", err.stack || err);
1188
- return reject(err);
1421
+ compiler.close(() => reject(err));
1422
+ return;
1189
1423
  }
1190
1424
  if (stats?.hasErrors()) {
1191
1425
  const info = stats.toJson();
1192
1426
  logger.error("webpack", info.errors?.map((e) => e.message).join("\n"));
1193
- return reject(new Error("Webpack compilation errors"));
1427
+ compiler.close(() => reject(new Error("Webpack compilation errors")));
1428
+ return;
1194
1429
  }
1195
- resolve(stats);
1430
+ compiler.close((closeErr) => {
1431
+ if (closeErr) {
1432
+ return reject(closeErr);
1433
+ }
1434
+ resolve(stats);
1435
+ });
1196
1436
  });
1197
1437
  });
1198
1438
  }
1199
1439
 
1200
1440
  // src/bundler/rollup.ts
1201
1441
  var import_rollup = require("rollup");
1202
- var import_node_path12 = __toESM(require("path"), 1);
1203
1442
  async function runRollup(config, customInputOptions = {}, customOutputOptions = {}) {
1204
1443
  const isProd = config.env.isProd;
1205
1444
  let input = customInputOptions.input || config.scripts.entry;
1206
1445
  if (!input) {
1207
- input = import_node_path12.default.join(config.src.js, "main.js");
1446
+ input = resolveDefaultEntry(config.src.js);
1208
1447
  }
1209
1448
  const inputOptions = {
1210
1449
  ...config.scripts.rollupOptions,
@@ -1233,12 +1472,11 @@ async function runRollup(config, customInputOptions = {}, customOutputOptions =
1233
1472
 
1234
1473
  // src/bundler/esbuild.ts
1235
1474
  var esbuild = __toESM(require("esbuild"), 1);
1236
- var import_node_path13 = __toESM(require("path"), 1);
1237
1475
  async function runEsbuild(config, customOptions = {}) {
1238
1476
  const isProd = config.env.isProd;
1239
1477
  let entryPoints = customOptions.entryPoints || config.scripts.entry;
1240
1478
  if (!entryPoints) {
1241
- entryPoints = [import_node_path13.default.join(config.src.js, "main.js")];
1479
+ entryPoints = [resolveDefaultEntry(config.src.js)];
1242
1480
  }
1243
1481
  const defaultOptions = {
1244
1482
  entryPoints: Array.isArray(entryPoints) ? entryPoints : typeof entryPoints === "string" ? [entryPoints] : entryPoints,
@@ -1287,7 +1525,8 @@ var ScriptTask = class extends BaseTask {
1287
1525
  };
1288
1526
 
1289
1527
  // src/tasks/html.ts
1290
- var import_node_path14 = __toESM(require("path"), 1);
1528
+ var import_node_path12 = __toESM(require("path"), 1);
1529
+ var import_node_fs4 = require("fs");
1291
1530
  var import_fast_glob3 = __toESM(require("fast-glob"), 1);
1292
1531
 
1293
1532
  // src/pipeline/transforms/htmlmin.ts
@@ -1319,10 +1558,18 @@ function transformReplace(options, replacement) {
1319
1558
  return async (file2) => {
1320
1559
  let content = file2.toString();
1321
1560
  for (const rule of rules) {
1322
- if (typeof rule.replacement === "function") {
1323
- content = content.replace(rule.substr, rule.replacement);
1324
- } else {
1325
- content = content.replace(rule.substr, rule.replacement);
1561
+ if (typeof rule.substr === "string") {
1562
+ if (typeof rule.replacement === "function") {
1563
+ content = content.replaceAll(rule.substr, rule.replacement);
1564
+ } else {
1565
+ content = content.replaceAll(rule.substr, rule.replacement);
1566
+ }
1567
+ } else if (rule.substr instanceof RegExp) {
1568
+ if (typeof rule.replacement === "function") {
1569
+ content = content.replace(rule.substr, rule.replacement);
1570
+ } else {
1571
+ content = content.replace(rule.substr, rule.replacement);
1572
+ }
1326
1573
  }
1327
1574
  }
1328
1575
  file2.contents = Buffer.from(content);
@@ -1368,15 +1615,21 @@ var HtmlTask = class extends BaseTask {
1368
1615
  const customTemplate = config.scripts.htmlPluginOptions?.template;
1369
1616
  let pipeline;
1370
1617
  if (customTemplate) {
1371
- const templatePath = import_node_path14.default.isAbsolute(customTemplate) ? customTemplate : import_node_path14.default.join(config.workspace, customTemplate);
1618
+ const templatePath = import_node_path12.default.isAbsolute(customTemplate) ? customTemplate : import_node_path12.default.join(config.workspace, customTemplate);
1372
1619
  pipeline = Pipeline.from(templatePath, {
1373
1620
  cwd: config.workspace,
1374
- base: import_node_path14.default.dirname(templatePath)
1621
+ base: import_node_path12.default.dirname(templatePath)
1375
1622
  });
1376
1623
  } else {
1377
1624
  const templateDir = config.scripts.injectHtml ? config.src.base : config.src.html;
1378
- const pattern = import_node_path14.default.join(templateDir, "*.html");
1379
- pipeline = Pipeline.from(pattern, {
1625
+ const patterns = [import_node_path12.default.join(templateDir, "*.html")];
1626
+ if (config.pwa.manifest) {
1627
+ const manifestPattern = import_node_path12.default.join(templateDir, config.pwa.manifest);
1628
+ if ((0, import_node_fs4.existsSync)(import_node_path12.default.isAbsolute(manifestPattern) ? manifestPattern : import_node_path12.default.join(config.workspace, manifestPattern))) {
1629
+ patterns.push(manifestPattern);
1630
+ }
1631
+ }
1632
+ pipeline = Pipeline.from(patterns, {
1380
1633
  cwd: config.workspace,
1381
1634
  base: templateDir
1382
1635
  });
@@ -1458,7 +1711,9 @@ var HtmlTask = class extends BaseTask {
1458
1711
  pipeline.pipe(async (file2) => {
1459
1712
  if (/\.html$/i.test(file2.extname)) {
1460
1713
  let content = file2.toString();
1461
- const entries = typeof config.scripts.entry === "object" && !Array.isArray(config.scripts.entry) ? Object.keys(config.scripts.entry) : ["main"];
1714
+ const entryNames = typeof config.scripts.entry === "object" && !Array.isArray(config.scripts.entry) ? Object.keys(config.scripts.entry) : ["main"];
1715
+ const vendorName = config.scripts.vendorName || "vendor";
1716
+ const entries = config.scripts.extractAllVendors ? [vendorName, ...entryNames] : entryNames;
1462
1717
  const jsDir = config.env.isProd ? config.paths.target.js : config.paths.tmp.js;
1463
1718
  const jsPathPrefix = config.assets.virtualDir ? `/${config.assets.virtualDir}/${jsDir}` : `/${jsDir}`;
1464
1719
  const destJsFolder = config.dest.js;
@@ -1468,18 +1723,24 @@ var HtmlTask = class extends BaseTask {
1468
1723
  )
1469
1724
  ).map((entryName) => {
1470
1725
  let actualFilename = `${entryName}.js`;
1726
+ const hasUnhashed = (0, import_node_fs4.existsSync)(import_node_path12.default.join(destJsFolder, actualFilename));
1727
+ let found = hasUnhashed;
1471
1728
  try {
1472
1729
  const matched = import_fast_glob3.default.sync(`${entryName}.*.js`, { cwd: destJsFolder });
1473
1730
  if (matched.length) {
1474
1731
  const valid = matched.find((f) => !f.endsWith(".map") && !f.endsWith(".txt"));
1475
1732
  if (valid) {
1476
1733
  actualFilename = valid;
1734
+ found = true;
1477
1735
  }
1478
1736
  }
1479
1737
  } catch {
1480
1738
  }
1739
+ if (entryName === vendorName && config.scripts.extractAllVendors && !found) {
1740
+ return "";
1741
+ }
1481
1742
  return `<script defer src="${jsPathPrefix}/${actualFilename}"></script>`;
1482
- }).join("\n");
1743
+ }).filter(Boolean).join("\n");
1483
1744
  if (scriptTags) {
1484
1745
  if (content.includes("</body>")) {
1485
1746
  content = content.replace("</body>", `${scriptTags}
@@ -1494,6 +1755,50 @@ ${scriptTags}`;
1494
1755
  return file2;
1495
1756
  });
1496
1757
  }
1758
+ if (config.env.isProd && config.html.analytics) {
1759
+ pipeline.pipe(async (file2) => {
1760
+ if (/\.html$/i.test(file2.extname)) {
1761
+ let content = file2.toString();
1762
+ const { custom, google } = config.html.analytics;
1763
+ if (custom && custom.src) {
1764
+ const attrs = [
1765
+ `src="${custom.src}"`,
1766
+ custom.siteId !== void 0 ? `data-website-id="${custom.siteId}"` : "",
1767
+ custom.defer !== false ? "defer" : "",
1768
+ custom.async ? "async" : ""
1769
+ ].filter(Boolean).join(" ");
1770
+ const customTag = `<script ${attrs}></script>`;
1771
+ if (content.includes("</head>")) {
1772
+ content = content.replace("</head>", ` ${customTag}
1773
+ </head>`);
1774
+ } else {
1775
+ content = `${customTag}
1776
+ ${content}`;
1777
+ }
1778
+ }
1779
+ if (google) {
1780
+ const gaSnippet = [
1781
+ `<script async src="https://www.googletagmanager.com/gtag/js?id=${google}"></script>`,
1782
+ "<script>",
1783
+ " window.dataLayer = window.dataLayer || [];",
1784
+ " function gtag(){dataLayer.push(arguments);}",
1785
+ " gtag('js', new Date());",
1786
+ ` gtag('config', '${google}');`,
1787
+ "</script>"
1788
+ ].join("\n");
1789
+ if (content.includes("</body>")) {
1790
+ content = content.replace("</body>", `${gaSnippet}
1791
+ </body>`);
1792
+ } else {
1793
+ content += `
1794
+ ${gaSnippet}`;
1795
+ }
1796
+ }
1797
+ file2.contents = Buffer.from(content);
1798
+ }
1799
+ return file2;
1800
+ });
1801
+ }
1497
1802
  if (config.env.isProd) {
1498
1803
  pipeline.pipe(transformHtmlmin(config.html.options));
1499
1804
  } else {
@@ -1517,35 +1822,36 @@ ${LIVE_RELOAD_SCRIPT}`;
1517
1822
  };
1518
1823
 
1519
1824
  // src/tasks/copy.ts
1520
- var import_node_path16 = __toESM(require("path"), 1);
1825
+ var import_node_path14 = __toESM(require("path"), 1);
1521
1826
 
1522
1827
  // src/pipeline/transforms/rename.ts
1523
- var import_node_path15 = __toESM(require("path"), 1);
1828
+ var import_node_path13 = __toESM(require("path"), 1);
1524
1829
  function transformRename(options = {}) {
1525
1830
  return async (file2) => {
1526
1831
  if (typeof options === "string") {
1527
- file2.path = import_node_path15.default.resolve(import_node_path15.default.dirname(file2.path), options);
1832
+ file2.path = import_node_path13.default.resolve(import_node_path13.default.dirname(file2.path), options);
1528
1833
  return file2;
1529
1834
  }
1530
1835
  if (typeof options === "function") {
1531
1836
  const parsed = {
1532
- dirname: import_node_path15.default.dirname(file2.path),
1837
+ dirname: import_node_path13.default.dirname(file2.path),
1533
1838
  basename: file2.stem,
1534
1839
  extname: file2.extname
1535
1840
  };
1536
1841
  const result = options(parsed);
1537
1842
  if (result) {
1538
- if (result.dirname) file2.path = import_node_path15.default.join(result.dirname, import_node_path15.default.basename(file2.path));
1843
+ if (result.dirname) file2.path = import_node_path13.default.join(result.dirname, import_node_path13.default.basename(file2.path));
1539
1844
  if (result.basename) file2.stem = result.basename;
1540
1845
  if (result.extname) file2.extname = result.extname;
1541
1846
  }
1542
1847
  return file2;
1543
1848
  }
1544
1849
  const { dirname, prefix = "", basename, suffix = "", extname } = options;
1545
- const currentDir = dirname ? import_node_path15.default.resolve(file2.cwd, dirname) : import_node_path15.default.dirname(file2.path);
1850
+ const currentDir = dirname ? import_node_path13.default.resolve(file2.cwd, dirname) : import_node_path13.default.dirname(file2.path);
1546
1851
  const base = basename !== void 0 ? basename : file2.stem;
1547
1852
  const ext = extname !== void 0 ? extname : file2.extname;
1548
- file2.path = import_node_path15.default.join(currentDir, `${prefix}${base}${suffix}${ext.startsWith(".") ? ext : `.${ext}`}`);
1853
+ const dotExt = ext ? ext.startsWith(".") ? ext : `.${ext}` : "";
1854
+ file2.path = import_node_path13.default.join(currentDir, `${prefix}${base}${suffix}${dotExt}`);
1549
1855
  return file2;
1550
1856
  };
1551
1857
  }
@@ -1564,13 +1870,13 @@ var CopyTask = class extends BaseTask {
1564
1870
  if (this.options.rename) {
1565
1871
  pipeline.pipe(transformRename(this.options.rename));
1566
1872
  }
1567
- const outDir = import_node_path16.default.isAbsolute(this.options.output) ? this.options.output : import_node_path16.default.join(config.workspace, this.options.output);
1873
+ const outDir = import_node_path14.default.isAbsolute(this.options.output) ? this.options.output : import_node_path14.default.join(config.workspace, this.options.output);
1568
1874
  await pipeline.dest(outDir);
1569
1875
  }
1570
1876
  };
1571
1877
 
1572
1878
  // src/tasks/remove.ts
1573
- var import_node_path17 = __toESM(require("path"), 1);
1879
+ var import_node_path15 = __toESM(require("path"), 1);
1574
1880
  var RemoveTask = class extends BaseTask {
1575
1881
  target;
1576
1882
  constructor(target) {
@@ -1580,7 +1886,7 @@ var RemoveTask = class extends BaseTask {
1580
1886
  async run(config) {
1581
1887
  const targets = Array.isArray(this.target) ? this.target : [this.target];
1582
1888
  const resolvedTargets = targets.map(
1583
- (t) => import_node_path17.default.isAbsolute(t) ? t : import_node_path17.default.join(config.workspace, t)
1889
+ (t) => import_node_path15.default.isAbsolute(t) ? t : import_node_path15.default.join(config.workspace, t)
1584
1890
  );
1585
1891
  const deleted = await file.remove(resolvedTargets);
1586
1892
  logger.warn("remove", `Removed: ${deleted.join(", ")}`);
@@ -1588,7 +1894,7 @@ var RemoveTask = class extends BaseTask {
1588
1894
  };
1589
1895
 
1590
1896
  // src/tasks/replace.ts
1591
- var import_node_path18 = __toESM(require("path"), 1);
1897
+ var import_node_path16 = __toESM(require("path"), 1);
1592
1898
  var ReplaceTask = class extends BaseTask {
1593
1899
  taskOptions;
1594
1900
  constructor(taskOptions) {
@@ -1600,7 +1906,7 @@ var ReplaceTask = class extends BaseTask {
1600
1906
  cwd: config.workspace
1601
1907
  });
1602
1908
  pipeline.pipe(transformReplace(this.taskOptions.options));
1603
- const outDir = import_node_path18.default.isAbsolute(this.taskOptions.output) ? this.taskOptions.output : import_node_path18.default.join(config.workspace, this.taskOptions.output);
1909
+ const outDir = import_node_path16.default.isAbsolute(this.taskOptions.output) ? this.taskOptions.output : import_node_path16.default.join(config.workspace, this.taskOptions.output);
1604
1910
  await pipeline.dest(outDir);
1605
1911
  }
1606
1912
  };
@@ -1610,12 +1916,12 @@ var import_fast_glob4 = __toESM(require("fast-glob"), 1);
1610
1916
  var import_promises3 = __toESM(require("fs/promises"), 1);
1611
1917
 
1612
1918
  // src/pipeline/transforms/cache.ts
1613
- var import_node_path19 = __toESM(require("path"), 1);
1919
+ var import_node_path17 = __toESM(require("path"), 1);
1614
1920
  var import_picomatch = __toESM(require("picomatch"), 1);
1615
1921
  function matchesAny(filePath, rules) {
1616
1922
  if (!rules || !rules.length) return false;
1617
1923
  const normalized = filePath.replace(/\\/g, "/");
1618
- const baseName = import_node_path19.default.basename(normalized);
1924
+ const baseName = import_node_path17.default.basename(normalized);
1619
1925
  for (const rawRule of rules) {
1620
1926
  if (typeof rawRule === "string") {
1621
1927
  const rule = rawRule.replace(/\\/g, "/");
@@ -1637,6 +1943,7 @@ var AssetRevisioner = class {
1637
1943
  ".html",
1638
1944
  "favicon.ico",
1639
1945
  "manifest.json",
1946
+ "*.webmanifest",
1640
1947
  "robots.txt",
1641
1948
  "*.ico",
1642
1949
  "workbox-sw.js",
@@ -1668,9 +1975,9 @@ var AssetRevisioner = class {
1668
1975
  const shouldRename = !alreadyHashed && !matchesAny(file2.path, this.options.dontRenameFile) && !matchesAny(file2.relative, this.options.dontRenameFile);
1669
1976
  if (shouldRename) {
1670
1977
  const fileHash = file.hash(file2.contents, hashLength);
1671
- const dir = import_node_path19.default.dirname(file2.path);
1978
+ const dir = import_node_path17.default.dirname(file2.path);
1672
1979
  const newFilename = `${file2.stem}.${fileHash}${file2.extname}`;
1673
- file2.path = import_node_path19.default.join(dir, newFilename);
1980
+ file2.path = import_node_path17.default.join(dir, newFilename);
1674
1981
  }
1675
1982
  if (alreadyHashed) {
1676
1983
  const unhashedRelative = file2.relative.replace(/\.[a-f0-9]{8}(\.[^.]+)$/i, "$1");
@@ -1686,8 +1993,8 @@ var AssetRevisioner = class {
1686
1993
  let content = file2.toString();
1687
1994
  for (const [orig, reved] of manifestEntries) {
1688
1995
  content = content.replaceAll(orig, reved);
1689
- const origBase = import_node_path19.default.basename(orig);
1690
- const revedBase = import_node_path19.default.basename(reved);
1996
+ const origBase = import_node_path17.default.basename(orig);
1997
+ const revedBase = import_node_path17.default.basename(reved);
1691
1998
  const escapedBase = origBase.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1692
1999
  const baseRegex = new RegExp(`${escapedBase}(?![a-zA-Z0-9_])`, "g");
1693
2000
  content = content.replace(baseRegex, revedBase);
@@ -1700,7 +2007,7 @@ var AssetRevisioner = class {
1700
2007
  const manifestFile = new VirtualFile({
1701
2008
  cwd: files[0]?.cwd || process.cwd(),
1702
2009
  base: firstBase,
1703
- path: import_node_path19.default.join(firstBase, manifestName),
2010
+ path: import_node_path17.default.join(firstBase, manifestName),
1704
2011
  contents: JSON.stringify(this.manifest, null, 2)
1705
2012
  });
1706
2013
  outputFiles.push(manifestFile);
@@ -1715,7 +2022,15 @@ var CacheTask = class extends BaseTask {
1715
2022
  }
1716
2023
  async run(config) {
1717
2024
  const destDir = config.dest.base;
1718
- const filesToRev = await (0, import_fast_glob4.default)(["**/*"], {
2025
+ const assetGlobs = [
2026
+ `${config.paths.target.css}/**/*`,
2027
+ `${config.paths.target.js}/**/*`,
2028
+ `${config.paths.target.img}/**/*`,
2029
+ `${config.paths.target.font}/**/*`,
2030
+ `${config.paths.target.media}/**/*`,
2031
+ "*.html"
2032
+ ];
2033
+ const filesToRev = await (0, import_fast_glob4.default)(assetGlobs, {
1719
2034
  cwd: destDir,
1720
2035
  absolute: true,
1721
2036
  onlyFiles: true
@@ -1741,10 +2056,14 @@ var CacheTask = class extends BaseTask {
1741
2056
  ".html",
1742
2057
  "favicon.ico",
1743
2058
  "manifest.json",
2059
+ "*.webmanifest",
1744
2060
  "robots.txt",
1745
2061
  "*.ico",
1746
2062
  "icons/*",
1747
2063
  "**/icons/**",
2064
+ "sw.js",
2065
+ "service-worker.js",
2066
+ "workbox-sw.js",
1748
2067
  ...config.assets.excludes || [],
1749
2068
  ...config.assets.options?.dontRenameFile || []
1750
2069
  ]
@@ -1764,7 +2083,7 @@ var CacheTask = class extends BaseTask {
1764
2083
  };
1765
2084
 
1766
2085
  // src/tasks/publish.ts
1767
- var import_node_path20 = __toESM(require("path"), 1);
2086
+ var import_node_path18 = __toESM(require("path"), 1);
1768
2087
  var PublishTask = class extends BaseTask {
1769
2088
  options;
1770
2089
  constructor(options = {}) {
@@ -1785,17 +2104,17 @@ var PublishTask = class extends BaseTask {
1785
2104
  await this.publishItem(config, input, output, renameOptions);
1786
2105
  } else {
1787
2106
  const srcDir = config.dest.base;
1788
- const targetDir = config.assets.static || import_node_path20.default.join(config.assets.root, config.assets.mainDir);
2107
+ const targetDir = config.assets.static || import_node_path18.default.join(config.assets.root, config.assets.mainDir);
1789
2108
  const pipeline = Pipeline.from(["**/*"], {
1790
2109
  cwd: srcDir,
1791
2110
  base: srcDir
1792
2111
  });
1793
- await pipeline.dest(import_node_path20.default.resolve(config.workspace, targetDir));
2112
+ await pipeline.dest(import_node_path18.default.resolve(config.workspace, targetDir));
1794
2113
  }
1795
2114
  }
1796
2115
  async publishItem(config, input, output, rename) {
1797
- const srcPath = import_node_path20.default.isAbsolute(input) ? input : import_node_path20.default.join(config.dest.base, input);
1798
- const destDir = import_node_path20.default.isAbsolute(output) ? output : import_node_path20.default.join(config.workspace, config.assets.root, output);
2116
+ const srcPath = import_node_path18.default.isAbsolute(input) ? input : import_node_path18.default.join(config.dest.base, input);
2117
+ const destDir = import_node_path18.default.isAbsolute(output) ? output : import_node_path18.default.join(config.workspace, config.assets.root, output);
1799
2118
  const pipeline = Pipeline.from(srcPath, {
1800
2119
  cwd: config.dest.base
1801
2120
  });
@@ -1807,10 +2126,10 @@ var PublishTask = class extends BaseTask {
1807
2126
  };
1808
2127
 
1809
2128
  // src/tasks/pwa.ts
1810
- var import_node_path21 = __toESM(require("path"), 1);
2129
+ var import_node_path19 = __toESM(require("path"), 1);
1811
2130
  var import_promises4 = __toESM(require("fs/promises"), 1);
1812
- var import_node_fs3 = require("fs");
1813
- var import_node_module = require("module");
2131
+ var import_node_fs5 = require("fs");
2132
+ var import_node_module2 = require("module");
1814
2133
  var import_workbox_build = require("workbox-build");
1815
2134
  var PwaTask = class extends BaseTask {
1816
2135
  options;
@@ -1820,12 +2139,12 @@ var PwaTask = class extends BaseTask {
1820
2139
  }
1821
2140
  async run(config) {
1822
2141
  const globDirectory = config.dest.base;
1823
- const swDest = import_node_path21.default.join(globDirectory, config.pwa.swDestFilename);
1824
- const swSrc = import_node_path21.default.join(config.src.base, config.pwa.swSrcFilename);
1825
- const require2 = (0, import_node_module.createRequire)(importMetaUrl);
2142
+ const swDest = import_node_path19.default.join(globDirectory, config.pwa.swDestFilename);
2143
+ const swSrc = import_node_path19.default.join(config.src.base, config.pwa.swSrcFilename);
2144
+ const require2 = (0, import_node_module2.createRequire)(importMetaUrl);
1826
2145
  const candidatePaths = [
1827
- import_node_path21.default.join(config.workspace, "node_modules/workbox-sw/build/workbox-sw.js"),
1828
- import_node_path21.default.join(config.workspace, "node_modules/workbox-sw/controllers/WorkboxSW.mjs")
2146
+ import_node_path19.default.join(config.workspace, "node_modules/workbox-sw/build/workbox-sw.js"),
2147
+ import_node_path19.default.join(config.workspace, "node_modules/workbox-sw/controllers/WorkboxSW.mjs")
1829
2148
  ];
1830
2149
  try {
1831
2150
  const resolved = require2.resolve("workbox-sw/build/workbox-sw.js");
@@ -1834,17 +2153,13 @@ var PwaTask = class extends BaseTask {
1834
2153
  }
1835
2154
  try {
1836
2155
  const resolvedPkg = require2.resolve("workbox-sw");
1837
- candidatePaths.push(import_node_path21.default.join(import_node_path21.default.dirname(resolvedPkg), "build/workbox-sw.js"));
2156
+ candidatePaths.push(import_node_path19.default.join(import_node_path19.default.dirname(resolvedPkg), "build/workbox-sw.js"));
1838
2157
  } catch {
1839
2158
  }
1840
2159
  for (const p of candidatePaths) {
1841
- if ((0, import_node_fs3.existsSync)(p)) {
1842
- const destFile = import_node_path21.default.join(globDirectory, "workbox-sw.js");
2160
+ if ((0, import_node_fs5.existsSync)(p)) {
2161
+ const destFile = import_node_path19.default.join(globDirectory, "workbox-sw.js");
1843
2162
  await import_promises4.default.copyFile(p, destFile);
1844
- const mapFile = `${p}.map`;
1845
- if ((0, import_node_fs3.existsSync)(mapFile)) {
1846
- await import_promises4.default.copyFile(mapFile, import_node_path21.default.join(globDirectory, "workbox-sw.js.map"));
1847
- }
1848
2163
  break;
1849
2164
  }
1850
2165
  }
@@ -1866,18 +2181,11 @@ var PwaTask = class extends BaseTask {
1866
2181
  const { count, size } = await (0, import_workbox_build.injectManifest)(mergedOptions);
1867
2182
  logger.info("pwa", `Injected manifest into '${swDest}', precaching ${count} files (${size} bytes)`);
1868
2183
  }
1869
- if ((0, import_node_fs3.existsSync)(swDest) && config.pwa.version) {
2184
+ if ((0, import_node_fs5.existsSync)(swDest) && config.pwa.version) {
1870
2185
  let swContent = await import_promises4.default.readFile(swDest, "utf-8");
1871
2186
  swContent = swContent.replaceAll("{{ version }}", config.pwa.version).replaceAll("{{version}}", config.pwa.version);
1872
2187
  await import_promises4.default.writeFile(swDest, swContent, "utf-8");
1873
2188
  }
1874
- const swJsDest = import_node_path21.default.join(globDirectory, "sw.js");
1875
- const serviceWorkerJsDest = import_node_path21.default.join(globDirectory, "service-worker.js");
1876
- if ((0, import_node_fs3.existsSync)(serviceWorkerJsDest) && !(0, import_node_fs3.existsSync)(swJsDest)) {
1877
- await import_promises4.default.copyFile(serviceWorkerJsDest, swJsDest);
1878
- } else if ((0, import_node_fs3.existsSync)(swJsDest) && !(0, import_node_fs3.existsSync)(serviceWorkerJsDest)) {
1879
- await import_promises4.default.copyFile(swJsDest, serviceWorkerJsDest);
1880
- }
1881
2189
  } catch (err) {
1882
2190
  logger.warn("pwa", `Service worker generation failed: ${err.message || err}`);
1883
2191
  }
@@ -1885,9 +2193,10 @@ var PwaTask = class extends BaseTask {
1885
2193
  };
1886
2194
 
1887
2195
  // src/tasks/zip.ts
1888
- var import_node_fs4 = __toESM(require("fs"), 1);
1889
- var import_node_path22 = __toESM(require("path"), 1);
2196
+ var import_node_fs6 = __toESM(require("fs"), 1);
2197
+ var import_node_path20 = __toESM(require("path"), 1);
1890
2198
  var import_archiver = __toESM(require("archiver"), 1);
2199
+ var import_fast_glob5 = __toESM(require("fast-glob"), 1);
1891
2200
  var ZipTask = class extends BaseTask {
1892
2201
  options;
1893
2202
  constructor(options = {}) {
@@ -1896,12 +2205,12 @@ var ZipTask = class extends BaseTask {
1896
2205
  }
1897
2206
  async run(config) {
1898
2207
  const input = this.options.input || config.dest.base;
1899
- const outputDir = this.options.output ? import_node_path22.default.isAbsolute(this.options.output) ? this.options.output : import_node_path22.default.join(config.workspace, this.options.output) : config.workspace;
2208
+ const outputDir = this.options.output ? import_node_path20.default.isAbsolute(this.options.output) ? this.options.output : import_node_path20.default.join(config.workspace, this.options.output) : config.workspace;
1900
2209
  const filename = this.options.filename || "archive.zip";
1901
- const zipPath = import_node_path22.default.join(outputDir, filename);
2210
+ const zipPath = import_node_path20.default.join(outputDir, filename);
1902
2211
  await file.ensureDir(outputDir);
1903
2212
  return new Promise((resolve, reject) => {
1904
- const outputStream = import_node_fs4.default.createWriteStream(zipPath);
2213
+ const outputStream = import_node_fs6.default.createWriteStream(zipPath);
1905
2214
  const archive = (0, import_archiver.default)("zip", { zlib: { level: 9 } });
1906
2215
  outputStream.on("close", () => {
1907
2216
  logger.success("zip", `Created ${zipPath} (${archive.pointer()} total bytes)`);
@@ -1914,13 +2223,24 @@ var ZipTask = class extends BaseTask {
1914
2223
  archive.pipe(outputStream);
1915
2224
  const inputs = Array.isArray(input) ? input : [input];
1916
2225
  for (const item of inputs) {
1917
- const fullPath = import_node_path22.default.isAbsolute(item) ? item : import_node_path22.default.join(config.workspace, item);
1918
- if (import_node_fs4.default.existsSync(fullPath)) {
1919
- const stat = import_node_fs4.default.statSync(fullPath);
1920
- if (stat.isDirectory()) {
1921
- archive.directory(fullPath, false);
1922
- } else {
1923
- archive.file(fullPath, { name: import_node_path22.default.basename(fullPath) });
2226
+ const isGlob = /[*?{}]/.test(item);
2227
+ if (isGlob) {
2228
+ const base = item.split("*")[0].replace(/\/+$/, "") || ".";
2229
+ const matched = import_fast_glob5.default.sync(item, { cwd: config.workspace, onlyFiles: true, dot: true });
2230
+ for (const relPath of matched) {
2231
+ const fullFilePath = import_node_path20.default.join(config.workspace, relPath);
2232
+ const zipName = import_node_path20.default.relative(base, relPath);
2233
+ archive.file(fullFilePath, { name: zipName });
2234
+ }
2235
+ } else {
2236
+ const fullPath = import_node_path20.default.isAbsolute(item) ? item : import_node_path20.default.join(config.workspace, item);
2237
+ if (import_node_fs6.default.existsSync(fullPath)) {
2238
+ const stat = import_node_fs6.default.statSync(fullPath);
2239
+ if (stat.isDirectory()) {
2240
+ archive.directory(fullPath, false);
2241
+ } else {
2242
+ archive.file(fullPath, { name: import_node_path20.default.basename(fullPath) });
2243
+ }
1924
2244
  }
1925
2245
  }
1926
2246
  }
@@ -1930,9 +2250,9 @@ var ZipTask = class extends BaseTask {
1930
2250
  };
1931
2251
 
1932
2252
  // src/tasks/ftp.ts
1933
- var import_node_path23 = __toESM(require("path"), 1);
2253
+ var import_node_path21 = __toESM(require("path"), 1);
1934
2254
  var import_ssh2 = require("ssh2");
1935
- var import_fast_glob5 = __toESM(require("fast-glob"), 1);
2255
+ var import_fast_glob6 = __toESM(require("fast-glob"), 1);
1936
2256
  var FtpTask = class extends BaseTask {
1937
2257
  ftpOptions;
1938
2258
  constructor(ftpOptions = {}) {
@@ -1951,7 +2271,7 @@ var FtpTask = class extends BaseTask {
1951
2271
  return;
1952
2272
  }
1953
2273
  const localFiles = this.ftpOptions.localFiles || config.dest.base;
1954
- const files = await (0, import_fast_glob5.default)(localFiles, { cwd: config.workspace, absolute: true, onlyFiles: true });
2274
+ const files = await (0, import_fast_glob6.default)(localFiles, { cwd: config.workspace, absolute: true, onlyFiles: true });
1955
2275
  if (!files.length) {
1956
2276
  logger.warn("ftp", "No files to upload");
1957
2277
  return;
@@ -1966,8 +2286,8 @@ var FtpTask = class extends BaseTask {
1966
2286
  }
1967
2287
  let pending = files.length;
1968
2288
  for (const file2 of files) {
1969
- const rel = import_node_path23.default.relative(config.workspace, file2);
1970
- const remoteFile = import_node_path23.default.posix.join(options.remotePath, rel);
2289
+ const rel = import_node_path21.default.relative(config.workspace, file2);
2290
+ const remoteFile = import_node_path21.default.posix.join(options.remotePath, rel);
1971
2291
  sftp.fastPut(file2, remoteFile, (putErr) => {
1972
2292
  if (putErr) {
1973
2293
  logger.error("ftp", `Failed uploading ${file2}: ${putErr.message}`);
@@ -1994,15 +2314,16 @@ var FtpTask = class extends BaseTask {
1994
2314
 
1995
2315
  // src/tasks/server.ts
1996
2316
  var import_node_http = __toESM(require("http"), 1);
1997
- var import_node_fs6 = __toESM(require("fs"), 1);
1998
- var import_node_path24 = __toESM(require("path"), 1);
2317
+ var import_node_fs8 = __toESM(require("fs"), 1);
2318
+ var import_node_path23 = __toESM(require("path"), 1);
1999
2319
  var import_connect = __toESM(require("connect"), 1);
2000
2320
  var import_serve_static = __toESM(require("serve-static"), 1);
2001
2321
  var import_ws = require("ws");
2002
2322
  var import_http_proxy_middleware = require("http-proxy-middleware");
2003
2323
 
2004
2324
  // src/watcher/index.ts
2005
- var import_node_fs5 = __toESM(require("fs"), 1);
2325
+ var import_node_fs7 = __toESM(require("fs"), 1);
2326
+ var import_node_path22 = __toESM(require("path"), 1);
2006
2327
  var import_picocolors3 = __toESM(require("picocolors"), 1);
2007
2328
  var FileWatcher = class {
2008
2329
  config;
@@ -2012,7 +2333,8 @@ var FileWatcher = class {
2012
2333
  styleTask;
2013
2334
  scriptTask;
2014
2335
  htmlTask;
2015
- watcher = null;
2336
+ watchers = [];
2337
+ isRebuilding = false;
2016
2338
  constructor(config, broadcast) {
2017
2339
  this.config = config;
2018
2340
  this.broadcast = broadcast;
@@ -2020,29 +2342,56 @@ var FileWatcher = class {
2020
2342
  this.scriptTask = new ScriptTask();
2021
2343
  this.htmlTask = new HtmlTask();
2022
2344
  }
2345
+ getWatchDirs() {
2346
+ const candidates = [
2347
+ this.config.src.base,
2348
+ ...this.config.scripts.includeJsResource || [],
2349
+ ...this.config.styles.atImportPaths || []
2350
+ ];
2351
+ const resolved = candidates.filter(Boolean).map((dir) => import_node_path22.default.isAbsolute(dir) ? dir : import_node_path22.default.resolve(this.config.workspace, dir)).filter((dir) => import_node_fs7.default.existsSync(dir) && !dir.includes(`${import_node_path22.default.sep}node_modules`));
2352
+ const unique = Array.from(new Set(resolved)).sort((a, b) => a.length - b.length);
2353
+ return unique.filter(
2354
+ (dir, index) => !unique.slice(0, index).some((parent) => dir.startsWith(`${parent}${import_node_path22.default.sep}`))
2355
+ );
2356
+ }
2023
2357
  start() {
2024
- const watchDir = this.config.src.base;
2025
- if (!import_node_fs5.default.existsSync(watchDir)) return;
2026
- logger.info("watch", `Watching for file changes in ${import_picocolors3.default.cyan(watchDir)}`);
2027
- try {
2028
- this.watcher = import_node_fs5.default.watch(watchDir, { recursive: true }, (eventType, filename) => {
2029
- if (!filename) return;
2030
- this.pendingFiles.add(filename);
2031
- if (this.debounceTimer) clearTimeout(this.debounceTimer);
2032
- this.debounceTimer = setTimeout(() => {
2033
- this.handleChanges();
2034
- }, 50);
2035
- });
2036
- } catch (err) {
2037
- logger.warn("watch", `Native recursive watch failed: ${err.message}`);
2358
+ const watchDirs = this.getWatchDirs();
2359
+ if (!watchDirs.length) return;
2360
+ for (const watchDir of watchDirs) {
2361
+ logger.info("watch", `Watching for file changes in ${import_picocolors3.default.cyan(watchDir)}`);
2362
+ try {
2363
+ const watcher = import_node_fs7.default.watch(watchDir, { recursive: true }, (_eventType, filename) => {
2364
+ if (!filename) return;
2365
+ const normalized = filename.replace(/\\/g, "/");
2366
+ if (normalized.includes("node_modules/") || normalized.startsWith(".git/")) {
2367
+ return;
2368
+ }
2369
+ this.pendingFiles.add(filename);
2370
+ if (this.debounceTimer) clearTimeout(this.debounceTimer);
2371
+ this.debounceTimer = setTimeout(() => {
2372
+ this.handleChanges();
2373
+ }, 50);
2374
+ });
2375
+ this.watchers.push(watcher);
2376
+ } catch (err) {
2377
+ logger.warn("watch", `Native recursive watch failed for ${watchDir}: ${err.message}`);
2378
+ }
2038
2379
  }
2039
2380
  }
2040
2381
  async handleChanges() {
2382
+ if (this.isRebuilding) {
2383
+ this.debounceTimer = setTimeout(() => this.handleChanges(), 50);
2384
+ return;
2385
+ }
2041
2386
  const changed = Array.from(this.pendingFiles);
2042
2387
  this.pendingFiles.clear();
2388
+ if (!changed.length) return;
2043
2389
  const hasStyle = changed.some((f) => /\.(scss|sass|less|css)$/i.test(f));
2044
- const hasScript = changed.some((f) => /\.(js|mjs|cjs|ts|jsx|tsx)$/i.test(f));
2390
+ const hasScript = changed.some(
2391
+ (f) => /\.(js|mjs|cjs|ts|jsx|tsx|vue|md|json)$/i.test(f)
2392
+ );
2045
2393
  const hasHtml = changed.some((f) => /\.html$/i.test(f));
2394
+ this.isRebuilding = true;
2046
2395
  try {
2047
2396
  if (hasStyle) {
2048
2397
  const start = performance.now();
@@ -2070,13 +2419,19 @@ var FileWatcher = class {
2070
2419
  }
2071
2420
  } catch (err) {
2072
2421
  logger.error("watch", `Incremental rebuild failed: ${err?.message || err}`);
2422
+ } finally {
2423
+ this.isRebuilding = false;
2073
2424
  }
2074
2425
  }
2075
2426
  stop() {
2076
- if (this.watcher) {
2077
- this.watcher.close();
2078
- this.watcher = null;
2427
+ if (this.debounceTimer) {
2428
+ clearTimeout(this.debounceTimer);
2429
+ this.debounceTimer = null;
2430
+ }
2431
+ for (const watcher of this.watchers) {
2432
+ watcher.close();
2079
2433
  }
2434
+ this.watchers = [];
2080
2435
  }
2081
2436
  };
2082
2437
 
@@ -2114,13 +2469,13 @@ var ServerTask = class extends BaseTask {
2114
2469
  app.use((req, res, next) => {
2115
2470
  if (req.url === "/manifest.json" || req.url?.endsWith("/manifest.json")) {
2116
2471
  const candidates = [
2117
- import_node_path24.default.join(config.dest.base, "manifest.json"),
2118
- import_node_path24.default.join(config.src.base, "manifest.json"),
2119
- import_node_path24.default.join(config.workspace, "manifest.json")
2472
+ import_node_path23.default.join(config.dest.base, "manifest.json"),
2473
+ import_node_path23.default.join(config.src.base, "manifest.json"),
2474
+ import_node_path23.default.join(config.workspace, "manifest.json")
2120
2475
  ];
2121
- const file2 = candidates.find((f) => import_node_fs6.default.existsSync(f));
2476
+ const file2 = candidates.find((f) => import_node_fs8.default.existsSync(f));
2122
2477
  if (file2) {
2123
- let content = import_node_fs6.default.readFileSync(file2, "utf-8");
2478
+ let content = import_node_fs8.default.readFileSync(file2, "utf-8");
2124
2479
  const replacement = config.assets.virtualDir ? `/${config.assets.virtualDir}` : "";
2125
2480
  content = content.replaceAll("%PUBLIC_URL%", replacement);
2126
2481
  res.setHeader("Content-Type", "application/json; charset=utf-8");
@@ -2141,32 +2496,56 @@ var ServerTask = class extends BaseTask {
2141
2496
  if (config.paths.tmp.js && config.paths.tmp.js !== config.paths.source.js) {
2142
2497
  app.use("/" + config.paths.tmp.js, (0, import_serve_static.default)(config.dest.js));
2143
2498
  }
2144
- app.use("/chunk", (0, import_serve_static.default)(import_node_path24.default.join(config.dest.js, "chunk")));
2145
- app.use("/chunk", (0, import_serve_static.default)(import_node_path24.default.join(config.dest.base, "chunk")));
2499
+ app.use("/chunk", (0, import_serve_static.default)(import_node_path23.default.join(config.dest.js, "chunk")));
2500
+ app.use("/chunk", (0, import_serve_static.default)(import_node_path23.default.join(config.dest.base, "chunk")));
2146
2501
  if (config.paths.source.img) {
2147
2502
  app.use(
2148
2503
  "/" + config.paths.source.img,
2149
- (0, import_serve_static.default)(import_node_path24.default.join(config.src.base, config.paths.source.img))
2504
+ (0, import_serve_static.default)(import_node_path23.default.join(config.src.base, config.paths.source.img))
2150
2505
  );
2151
2506
  }
2152
2507
  if (config.paths.tmp.img) {
2153
2508
  app.use("/" + config.paths.tmp.img, (0, import_serve_static.default)(config.dest.img));
2154
2509
  }
2155
- app.use("/img", (0, import_serve_static.default)(import_node_path24.default.join(config.dest.base, "img")));
2156
- app.use("/img", (0, import_serve_static.default)(import_node_path24.default.join(config.dest.js, "img")));
2510
+ app.use("/img", (0, import_serve_static.default)(import_node_path23.default.join(config.dest.base, "img")));
2511
+ app.use("/img", (0, import_serve_static.default)(import_node_path23.default.join(config.dest.js, "img")));
2157
2512
  if (config.paths.source.font) {
2158
2513
  app.use(
2159
2514
  "/" + config.paths.source.font,
2160
- (0, import_serve_static.default)(import_node_path24.default.join(config.src.base, config.paths.source.font))
2515
+ (0, import_serve_static.default)(import_node_path23.default.join(config.src.base, config.paths.source.font))
2161
2516
  );
2162
2517
  }
2163
2518
  if (config.paths.tmp.font) {
2164
2519
  app.use("/" + config.paths.tmp.font, (0, import_serve_static.default)(config.dest.font));
2165
2520
  }
2166
- app.use("/font", (0, import_serve_static.default)(import_node_path24.default.join(config.dest.base, "font")));
2167
- app.use("/font", (0, import_serve_static.default)(import_node_path24.default.join(config.dest.js, "font")));
2168
- app.use("/fonts", (0, import_serve_static.default)(import_node_path24.default.join(config.src.base, "fonts")));
2169
- app.use("/fonts", (0, import_serve_static.default)(import_node_path24.default.join(config.dest.base, "fonts")));
2521
+ app.use("/font", (0, import_serve_static.default)(import_node_path23.default.join(config.dest.base, "font")));
2522
+ app.use("/font", (0, import_serve_static.default)(import_node_path23.default.join(config.dest.js, "font")));
2523
+ app.use("/fonts", (0, import_serve_static.default)(import_node_path23.default.join(config.src.base, "fonts")));
2524
+ app.use("/fonts", (0, import_serve_static.default)(import_node_path23.default.join(config.dest.base, "fonts")));
2525
+ if (config.server.serveStatic) {
2526
+ const staticEntries = Array.isArray(config.server.serveStatic) ? config.server.serveStatic : [config.server.serveStatic];
2527
+ for (const entry of staticEntries) {
2528
+ if (typeof entry === "string") {
2529
+ const absoluteDir = import_node_path23.default.isAbsolute(entry) ? entry : import_node_path23.default.join(config.workspace, entry);
2530
+ if (import_node_fs8.default.existsSync(absoluteDir)) {
2531
+ app.use((0, import_serve_static.default)(absoluteDir));
2532
+ }
2533
+ } else if (entry && typeof entry === "object") {
2534
+ const route = entry.route ? entry.route.startsWith("/") ? entry.route : `/${entry.route}` : "";
2535
+ const dirs = Array.isArray(entry.dir) ? entry.dir : [entry.dir];
2536
+ for (const dir of dirs) {
2537
+ const absoluteDir = import_node_path23.default.isAbsolute(dir) ? dir : import_node_path23.default.join(config.workspace, dir);
2538
+ if (import_node_fs8.default.existsSync(absoluteDir)) {
2539
+ if (route) {
2540
+ app.use(route, (0, import_serve_static.default)(absoluteDir));
2541
+ } else {
2542
+ app.use((0, import_serve_static.default)(absoluteDir));
2543
+ }
2544
+ }
2545
+ }
2546
+ }
2547
+ }
2548
+ }
2170
2549
  app.use((0, import_serve_static.default)(config.dest.base));
2171
2550
  app.use((0, import_serve_static.default)(config.src.base));
2172
2551
  app.use((0, import_serve_static.default)(config.workspace));
@@ -2175,15 +2554,15 @@ var ServerTask = class extends BaseTask {
2175
2554
  const isGetOrHead = req.method === "GET" || req.method === "HEAD";
2176
2555
  const isHtmlNav = !req.url?.includes(".") || req.headers.accept?.includes("text/html");
2177
2556
  if (isGetOrHead && isHtmlNav) {
2178
- const indexPath = import_node_path24.default.join(config.dest.html, "index.html");
2179
- const srcIndexPath = import_node_path24.default.join(config.src.base, "index.html");
2180
- const fileToServe = import_node_fs6.default.existsSync(indexPath) ? indexPath : srcIndexPath;
2181
- if (import_node_fs6.default.existsSync(fileToServe)) {
2557
+ const indexPath = import_node_path23.default.join(config.dest.html, "index.html");
2558
+ const srcIndexPath = import_node_path23.default.join(config.src.base, "index.html");
2559
+ const fileToServe = import_node_fs8.default.existsSync(indexPath) ? indexPath : srcIndexPath;
2560
+ if (import_node_fs8.default.existsSync(fileToServe)) {
2182
2561
  res.setHeader("Content-Type", "text/html; charset=utf-8");
2183
2562
  if (req.method === "HEAD") {
2184
2563
  return res.end();
2185
2564
  }
2186
- return import_node_fs6.default.createReadStream(fileToServe).pipe(res);
2565
+ return import_node_fs8.default.createReadStream(fileToServe).pipe(res);
2187
2566
  }
2188
2567
  }
2189
2568
  next();
@@ -2226,8 +2605,8 @@ var ServerTask = class extends BaseTask {
2226
2605
  };
2227
2606
 
2228
2607
  // src/tasks/static.ts
2229
- var import_node_path25 = __toESM(require("path"), 1);
2230
- var import_node_fs7 = require("fs");
2608
+ var import_node_path24 = __toESM(require("path"), 1);
2609
+ var import_node_fs9 = require("fs");
2231
2610
  var StaticTask = class extends BaseTask {
2232
2611
  constructor() {
2233
2612
  super({ name: "static", description: "Copy static assets, images, fonts, and manifest" });
@@ -2236,9 +2615,25 @@ var StaticTask = class extends BaseTask {
2236
2615
  const srcBase = config.src.base;
2237
2616
  const destBase = config.dest.base;
2238
2617
  const staticPatterns = [
2239
- import_node_path25.default.join(srcBase, "*.{ico,png,svg,json,txt,xml,webmanifest}"),
2240
- `!${import_node_path25.default.join(srcBase, "*.html")}`
2618
+ import_node_path24.default.join(srcBase, "*.{ico,png,svg,json,txt,xml,webmanifest}"),
2619
+ `!${import_node_path24.default.join(srcBase, "*.html")}`
2620
+ ];
2621
+ const extraIncludes = [
2622
+ ...config.extras?.includes || [],
2623
+ ...config.assets?.includes || []
2241
2624
  ];
2625
+ const extraExcludes = [
2626
+ ...config.extras?.excludes || [],
2627
+ ...config.assets?.excludes || []
2628
+ ];
2629
+ for (const inc of extraIncludes) {
2630
+ const pattern = import_node_path24.default.isAbsolute(inc) ? inc : import_node_path24.default.join(srcBase, inc);
2631
+ staticPatterns.push(pattern);
2632
+ }
2633
+ for (const exc of extraExcludes) {
2634
+ const pattern = import_node_path24.default.isAbsolute(exc) ? exc : import_node_path24.default.join(srcBase, exc);
2635
+ staticPatterns.push(`!${pattern}`);
2636
+ }
2242
2637
  const pipeline = Pipeline.from(staticPatterns, {
2243
2638
  cwd: config.workspace,
2244
2639
  base: srcBase
@@ -2253,53 +2648,30 @@ var StaticTask = class extends BaseTask {
2253
2648
  return file2;
2254
2649
  });
2255
2650
  await pipeline.dest(destBase);
2256
- if (config.src.img && (0, import_node_fs7.existsSync)(config.src.img)) {
2257
- const imgPipeline = Pipeline.from(import_node_path25.default.join(config.src.img, "**/*"), {
2651
+ if (config.src.img && (0, import_node_fs9.existsSync)(config.src.img)) {
2652
+ const imgPipeline = Pipeline.from(import_node_path24.default.join(config.src.img, "**/*"), {
2258
2653
  cwd: config.workspace,
2259
2654
  base: config.src.img
2260
2655
  });
2261
2656
  await imgPipeline.dest(config.dest.img);
2262
- if (config.paths.source.img && config.paths.target.img && config.paths.source.img !== config.paths.target.img) {
2263
- const compatPipeline = Pipeline.from(import_node_path25.default.join(config.src.img, "**/*"), {
2264
- cwd: config.workspace,
2265
- base: config.src.img
2266
- });
2267
- await compatPipeline.dest(import_node_path25.default.join(destBase, config.paths.source.img));
2268
- }
2269
2657
  }
2270
- if (config.src.font && (0, import_node_fs7.existsSync)(config.src.font)) {
2271
- const fontPipeline = Pipeline.from(import_node_path25.default.join(config.src.font, "**/*"), {
2658
+ if (config.src.font && (0, import_node_fs9.existsSync)(config.src.font)) {
2659
+ const fontPipeline = Pipeline.from(import_node_path24.default.join(config.src.font, "**/*"), {
2272
2660
  cwd: config.workspace,
2273
2661
  base: config.src.font
2274
2662
  });
2275
2663
  await fontPipeline.dest(config.dest.font);
2276
- const targetFontsDir = import_node_path25.default.join(destBase, "fonts");
2277
- if (config.dest.font !== targetFontsDir) {
2278
- const fontsPipeline = Pipeline.from(import_node_path25.default.join(config.src.font, "**/*"), {
2279
- cwd: config.workspace,
2280
- base: config.src.font
2281
- });
2282
- await fontsPipeline.dest(targetFontsDir);
2283
- }
2284
- const targetFontDir = import_node_path25.default.join(destBase, "font");
2285
- if (config.dest.font !== targetFontDir) {
2286
- const fontCompatPipeline = Pipeline.from(import_node_path25.default.join(config.src.font, "**/*"), {
2287
- cwd: config.workspace,
2288
- base: config.src.font
2289
- });
2290
- await fontCompatPipeline.dest(targetFontDir);
2291
- }
2292
2664
  }
2293
- if (config.src.media && (0, import_node_fs7.existsSync)(config.src.media)) {
2294
- const mediaPipeline = Pipeline.from(import_node_path25.default.join(config.src.media, "**/*"), {
2665
+ if (config.src.media && (0, import_node_fs9.existsSync)(config.src.media)) {
2666
+ const mediaPipeline = Pipeline.from(import_node_path24.default.join(config.src.media, "**/*"), {
2295
2667
  cwd: config.workspace,
2296
2668
  base: config.src.media
2297
2669
  });
2298
2670
  await mediaPipeline.dest(config.dest.media);
2299
2671
  }
2300
- const publicDir = import_node_path25.default.join(config.workspace, "public");
2301
- if ((0, import_node_fs7.existsSync)(publicDir)) {
2302
- const pubPipeline = Pipeline.from(import_node_path25.default.join(publicDir, "**/*"), {
2672
+ const publicDir = import_node_path24.default.join(config.workspace, "public");
2673
+ if ((0, import_node_fs9.existsSync)(publicDir)) {
2674
+ const pubPipeline = Pipeline.from(import_node_path24.default.join(publicDir, "**/*"), {
2303
2675
  cwd: config.workspace,
2304
2676
  base: publicDir
2305
2677
  });
@@ -2498,20 +2870,13 @@ var Balm = class {
2498
2870
  }
2499
2871
  try {
2500
2872
  if (this.beforeTask) {
2501
- await this.beforeTask();
2873
+ await this.beforeTask(this._config);
2502
2874
  }
2503
2875
  if (this._config.useDefaults) {
2504
2876
  await this.dag.runSeries(
2505
2877
  ["clean", "style", "script", "static", "html"],
2506
2878
  this._config
2507
2879
  );
2508
- }
2509
- for (let i = 1; ; i++) {
2510
- const recipeName = `recipe:${i}`;
2511
- if (!this.dag.hasTask(recipeName)) break;
2512
- await this.dag.executeTask(recipeName, this._config);
2513
- }
2514
- if (this._config.useDefaults) {
2515
2880
  if (this._config.env.isProd) {
2516
2881
  if (this._config.assets.cache) {
2517
2882
  await this.dag.executeTask("cache", this._config);
@@ -2519,12 +2884,18 @@ var Balm = class {
2519
2884
  if (this._config.pwa.enabled) {
2520
2885
  await this.dag.executeTask("pwa", this._config);
2521
2886
  }
2522
- } else {
2523
- await this.dag.executeTask("serve", this._config);
2524
2887
  }
2525
2888
  }
2889
+ for (let i = 1; ; i++) {
2890
+ const recipeName = `recipe:${i}`;
2891
+ if (!this.dag.hasTask(recipeName)) break;
2892
+ await this.dag.executeTask(recipeName, this._config);
2893
+ }
2894
+ if (this._config.useDefaults && !this._config.env.isProd) {
2895
+ await this.dag.executeTask("serve", this._config);
2896
+ }
2526
2897
  if (this.afterTask) {
2527
- await this.afterTask();
2898
+ await this.afterTask(this._config);
2528
2899
  }
2529
2900
  endTimer();
2530
2901
  } catch (err) {
@@ -2609,6 +2980,7 @@ var index_default = balm;
2609
2980
  localWorkspace,
2610
2981
  logger,
2611
2982
  resolveConfig,
2983
+ resolveDefaultEntry,
2612
2984
  runEsbuild,
2613
2985
  runRollup,
2614
2986
  runWebpack,