balm-core 6.0.0-alpha.3 → 6.0.0-alpha.4
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.
- package/CHANGELOG.md +9 -0
- package/dist/index.cjs +201 -150
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -1
- package/dist/index.d.ts +22 -1
- package/dist/index.js +196 -150
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -71,6 +71,7 @@ __export(index_exports, {
|
|
|
71
71
|
isArray: () => isArray,
|
|
72
72
|
isBoolean: () => isBoolean,
|
|
73
73
|
isFunction: () => isFunction,
|
|
74
|
+
isManifestFile: () => isManifestFile,
|
|
74
75
|
isObject: () => isObject,
|
|
75
76
|
isString: () => isString,
|
|
76
77
|
localResolve: () => localResolve,
|
|
@@ -78,11 +79,15 @@ __export(index_exports, {
|
|
|
78
79
|
logger: () => logger,
|
|
79
80
|
resolveConfig: () => resolveConfig,
|
|
80
81
|
resolveDefaultEntry: () => resolveDefaultEntry,
|
|
82
|
+
rewriteCssAssetUrls: () => rewriteCssAssetUrls,
|
|
83
|
+
rewriteHtmlAssetPaths: () => rewriteHtmlAssetPaths,
|
|
81
84
|
runEsbuild: () => runEsbuild,
|
|
82
85
|
runRollup: () => runRollup,
|
|
83
86
|
runWebpack: () => runWebpack,
|
|
84
87
|
setWorkspaces: () => setWorkspaces,
|
|
88
|
+
shouldUseTargetPaths: () => shouldUseTargetPaths,
|
|
85
89
|
toNamespace: () => toNamespace,
|
|
90
|
+
transformCssUrl: () => transformCssUrl,
|
|
86
91
|
transformHtmlmin: () => transformHtmlmin,
|
|
87
92
|
transformLess: () => transformLess,
|
|
88
93
|
transformPostcss: () => transformPostcss,
|
|
@@ -760,7 +765,7 @@ var CleanTask = class extends BaseTask {
|
|
|
760
765
|
};
|
|
761
766
|
|
|
762
767
|
// src/tasks/style.ts
|
|
763
|
-
var
|
|
768
|
+
var import_node_path11 = __toESM(require("path"), 1);
|
|
764
769
|
|
|
765
770
|
// src/pipeline/pipeline.ts
|
|
766
771
|
var import_node_path7 = __toESM(require("path"), 1);
|
|
@@ -844,7 +849,10 @@ var Pipeline = class _Pipeline {
|
|
|
844
849
|
this.transforms.push(async () => {
|
|
845
850
|
const patternArr = Array.isArray(patterns) ? patterns : [patterns];
|
|
846
851
|
const posPatterns = patternArr.filter((p) => !p.startsWith("!"));
|
|
847
|
-
const ignorePatterns =
|
|
852
|
+
const ignorePatterns = [
|
|
853
|
+
"**/.DS_Store",
|
|
854
|
+
...patternArr.filter((p) => p.startsWith("!")).map((p) => p.slice(1))
|
|
855
|
+
];
|
|
848
856
|
const fileList = [];
|
|
849
857
|
for (const p of posPatterns) {
|
|
850
858
|
let patternBase = this.base;
|
|
@@ -1098,6 +1106,96 @@ function transformPostcss(options = {}) {
|
|
|
1098
1106
|
};
|
|
1099
1107
|
}
|
|
1100
1108
|
|
|
1109
|
+
// src/pipeline/transforms/url.ts
|
|
1110
|
+
var import_node_path10 = __toESM(require("path"), 1);
|
|
1111
|
+
var CSS_ASSET_TYPES = ["img", "font", "media"];
|
|
1112
|
+
var HTML_ASSET_TYPES = ["css", "js", "img", "font", "media"];
|
|
1113
|
+
function escapeRegExp(value) {
|
|
1114
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1115
|
+
}
|
|
1116
|
+
function normalizeSegment(value) {
|
|
1117
|
+
return value ? value.replace(/^\/+|\/+$/g, "") : "";
|
|
1118
|
+
}
|
|
1119
|
+
function shouldUseTargetPaths(config) {
|
|
1120
|
+
return Boolean(config.env?.isProd || !config.inFrontend);
|
|
1121
|
+
}
|
|
1122
|
+
function isManifestFile(file2, config) {
|
|
1123
|
+
const manifestFilename = import_node_path10.default.basename(config.pwa?.manifest || "manifest.json");
|
|
1124
|
+
return file2.basename === manifestFilename || file2.extname.toLowerCase() === ".webmanifest";
|
|
1125
|
+
}
|
|
1126
|
+
function rewriteCssAssetUrls(content, config) {
|
|
1127
|
+
if (!shouldUseTargetPaths(config)) {
|
|
1128
|
+
return content;
|
|
1129
|
+
}
|
|
1130
|
+
let updated = content;
|
|
1131
|
+
for (const type of CSS_ASSET_TYPES) {
|
|
1132
|
+
const source = normalizeSegment(config.paths?.source?.[type]);
|
|
1133
|
+
const target = normalizeSegment(config.paths?.target?.[type]);
|
|
1134
|
+
if (!source || !target) continue;
|
|
1135
|
+
const sourceLeaf = source.split("/").pop();
|
|
1136
|
+
const candidates = Array.from(
|
|
1137
|
+
new Set(
|
|
1138
|
+
[source, sourceLeaf].filter(
|
|
1139
|
+
(item) => Boolean(item && item !== target)
|
|
1140
|
+
)
|
|
1141
|
+
)
|
|
1142
|
+
).sort((a, b) => b.length - a.length);
|
|
1143
|
+
if (!candidates.length) continue;
|
|
1144
|
+
const alternation = candidates.map(escapeRegExp).join("|");
|
|
1145
|
+
const relativeRegex = new RegExp(
|
|
1146
|
+
`(^|[\\s('",])((?:\\.{2}\\/)+)(?:${alternation})\\/`,
|
|
1147
|
+
"g"
|
|
1148
|
+
);
|
|
1149
|
+
updated = updated.replace(relativeRegex, `$1$2${target}/`);
|
|
1150
|
+
const rootUrlRegex = new RegExp(
|
|
1151
|
+
`(url\\(\\s*['"]?)\\/(?:${alternation})\\/`,
|
|
1152
|
+
"gi"
|
|
1153
|
+
);
|
|
1154
|
+
updated = updated.replace(rootUrlRegex, `$1/${target}/`);
|
|
1155
|
+
}
|
|
1156
|
+
return updated;
|
|
1157
|
+
}
|
|
1158
|
+
function rewriteHtmlAssetPaths(content, config) {
|
|
1159
|
+
if (!shouldUseTargetPaths(config)) {
|
|
1160
|
+
return content;
|
|
1161
|
+
}
|
|
1162
|
+
const sourceMap = /* @__PURE__ */ new Map();
|
|
1163
|
+
for (const type of HTML_ASSET_TYPES) {
|
|
1164
|
+
const source = normalizeSegment(config.paths?.source?.[type]);
|
|
1165
|
+
const target = normalizeSegment(config.paths?.target?.[type]);
|
|
1166
|
+
if (source && target && source !== target) {
|
|
1167
|
+
sourceMap.set(source, target);
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
if (!sourceMap.size) {
|
|
1171
|
+
return content;
|
|
1172
|
+
}
|
|
1173
|
+
const alternation = Array.from(sourceMap.keys()).sort((a, b) => b.length - a.length).map(escapeRegExp).join("|");
|
|
1174
|
+
const virtualDir = normalizeSegment(config.assets?.virtualDir);
|
|
1175
|
+
const virtualPrefix = virtualDir ? `\\/${escapeRegExp(virtualDir)}\\/|` : "";
|
|
1176
|
+
const prefixedRegex = new RegExp(
|
|
1177
|
+
`(^|["'\`=(,\\s])(${virtualPrefix}(?:\\.{1,2}\\/)+|\\/)(${alternation})\\/`,
|
|
1178
|
+
"g"
|
|
1179
|
+
);
|
|
1180
|
+
let updated = content.replace(
|
|
1181
|
+
prefixedRegex,
|
|
1182
|
+
(_, lead, prefix, src) => `${lead}${prefix}${sourceMap.get(src)}/`
|
|
1183
|
+
);
|
|
1184
|
+
const bareQuotedRegex = new RegExp(`(["'\`=])(${alternation})\\/`, "g");
|
|
1185
|
+
updated = updated.replace(
|
|
1186
|
+
bareQuotedRegex,
|
|
1187
|
+
(_, lead, src) => `${lead}${sourceMap.get(src)}/`
|
|
1188
|
+
);
|
|
1189
|
+
return updated;
|
|
1190
|
+
}
|
|
1191
|
+
function transformCssUrl(config) {
|
|
1192
|
+
return async (file2) => {
|
|
1193
|
+
if (!/\.css$/i.test(file2.extname)) return file2;
|
|
1194
|
+
file2.contents = Buffer.from(rewriteCssAssetUrls(file2.toString(), config));
|
|
1195
|
+
return file2;
|
|
1196
|
+
};
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1101
1199
|
// src/tasks/style.ts
|
|
1102
1200
|
var StyleTask = class extends BaseTask {
|
|
1103
1201
|
constructor() {
|
|
@@ -1105,9 +1203,9 @@ var StyleTask = class extends BaseTask {
|
|
|
1105
1203
|
}
|
|
1106
1204
|
async run(config) {
|
|
1107
1205
|
const ext = config.styles.extname;
|
|
1108
|
-
const srcPattern =
|
|
1206
|
+
const srcPattern = import_node_path11.default.join(config.src.css, `**/*.${ext}`);
|
|
1109
1207
|
const isProd = config.env.isProd;
|
|
1110
|
-
const pipeline = Pipeline.from([srcPattern, `!${
|
|
1208
|
+
const pipeline = Pipeline.from([srcPattern, `!${import_node_path11.default.join(config.src.css, "**/_*.scss")}`, `!${import_node_path11.default.join(config.src.css, "**/_*.less")}`], {
|
|
1111
1209
|
cwd: config.workspace,
|
|
1112
1210
|
base: config.src.css
|
|
1113
1211
|
});
|
|
@@ -1139,13 +1237,14 @@ var StyleTask = class extends BaseTask {
|
|
|
1139
1237
|
...config.styles.postcssLoaderOptions
|
|
1140
1238
|
})
|
|
1141
1239
|
);
|
|
1240
|
+
pipeline.pipe(transformCssUrl(config));
|
|
1142
1241
|
await pipeline.dest(config.dest.css);
|
|
1143
1242
|
}
|
|
1144
1243
|
};
|
|
1145
1244
|
|
|
1146
1245
|
// src/bundler/webpack.ts
|
|
1147
1246
|
var import_webpack = __toESM(require("webpack"), 1);
|
|
1148
|
-
var
|
|
1247
|
+
var import_node_path12 = __toESM(require("path"), 1);
|
|
1149
1248
|
var import_node_fs3 = require("fs");
|
|
1150
1249
|
var import_node_module = require("module");
|
|
1151
1250
|
var import_autoprefixer2 = __toESM(require("autoprefixer"), 1);
|
|
@@ -1163,7 +1262,7 @@ var BABEL_CONFIG_FILES = [
|
|
|
1163
1262
|
];
|
|
1164
1263
|
function resolveModule(pkgName, workspace) {
|
|
1165
1264
|
try {
|
|
1166
|
-
const workspaceRequire = (0, import_node_module.createRequire)(
|
|
1265
|
+
const workspaceRequire = (0, import_node_module.createRequire)(import_node_path12.default.join(workspace, "package.json"));
|
|
1167
1266
|
return workspaceRequire.resolve(pkgName);
|
|
1168
1267
|
} catch {
|
|
1169
1268
|
return coreRequire.resolve(pkgName);
|
|
@@ -1171,18 +1270,18 @@ function resolveModule(pkgName, workspace) {
|
|
|
1171
1270
|
}
|
|
1172
1271
|
function resolveWorkspacePaths(paths, workspace) {
|
|
1173
1272
|
if (!paths || !paths.length) return [];
|
|
1174
|
-
return paths.map((p) =>
|
|
1273
|
+
return paths.map((p) => import_node_path12.default.isAbsolute(p) ? p : import_node_path12.default.resolve(workspace, p));
|
|
1175
1274
|
}
|
|
1176
1275
|
function hasBabelConfig(config) {
|
|
1177
1276
|
if (config.scripts.babelLoaderOptions && Object.keys(config.scripts.babelLoaderOptions).length > 0) {
|
|
1178
1277
|
return true;
|
|
1179
1278
|
}
|
|
1180
1279
|
for (const filename of BABEL_CONFIG_FILES) {
|
|
1181
|
-
if ((0, import_node_fs3.existsSync)(
|
|
1280
|
+
if ((0, import_node_fs3.existsSync)(import_node_path12.default.join(config.workspace, filename))) {
|
|
1182
1281
|
return true;
|
|
1183
1282
|
}
|
|
1184
1283
|
}
|
|
1185
|
-
const pkgPath =
|
|
1284
|
+
const pkgPath = import_node_path12.default.join(config.workspace, "package.json");
|
|
1186
1285
|
if ((0, import_node_fs3.existsSync)(pkgPath)) {
|
|
1187
1286
|
try {
|
|
1188
1287
|
const pkg = JSON.parse((0, import_node_fs3.readFileSync)(pkgPath, "utf-8"));
|
|
@@ -1320,7 +1419,7 @@ async function runWebpack(config, customOptions = {}) {
|
|
|
1320
1419
|
}
|
|
1321
1420
|
const rawOutputPath = customOptions.output?.path;
|
|
1322
1421
|
const isCustomOutput = Boolean(rawOutputPath);
|
|
1323
|
-
const outputPath = isCustomOutput ?
|
|
1422
|
+
const outputPath = isCustomOutput ? import_node_path12.default.isAbsolute(rawOutputPath) ? rawOutputPath : import_node_path12.default.resolve(config.workspace, rawOutputPath) : config.dest.base;
|
|
1324
1423
|
const jsDir = isCustomOutput ? "" : isProd ? config.paths.target.js : config.paths.tmp.js;
|
|
1325
1424
|
const imgDir = isProd ? config.paths.target.img : config.paths.tmp.img;
|
|
1326
1425
|
const fontDir = isProd ? config.paths.target.font : config.paths.tmp.font;
|
|
@@ -1525,7 +1624,7 @@ var ScriptTask = class extends BaseTask {
|
|
|
1525
1624
|
};
|
|
1526
1625
|
|
|
1527
1626
|
// src/tasks/html.ts
|
|
1528
|
-
var
|
|
1627
|
+
var import_node_path13 = __toESM(require("path"), 1);
|
|
1529
1628
|
var import_node_fs4 = require("fs");
|
|
1530
1629
|
var import_fast_glob3 = __toESM(require("fast-glob"), 1);
|
|
1531
1630
|
|
|
@@ -1615,17 +1714,17 @@ var HtmlTask = class extends BaseTask {
|
|
|
1615
1714
|
const customTemplate = config.scripts.htmlPluginOptions?.template;
|
|
1616
1715
|
let pipeline;
|
|
1617
1716
|
if (customTemplate) {
|
|
1618
|
-
const templatePath =
|
|
1717
|
+
const templatePath = import_node_path13.default.isAbsolute(customTemplate) ? customTemplate : import_node_path13.default.join(config.workspace, customTemplate);
|
|
1619
1718
|
pipeline = Pipeline.from(templatePath, {
|
|
1620
1719
|
cwd: config.workspace,
|
|
1621
|
-
base:
|
|
1720
|
+
base: import_node_path13.default.dirname(templatePath)
|
|
1622
1721
|
});
|
|
1623
1722
|
} else {
|
|
1624
1723
|
const templateDir = config.scripts.injectHtml ? config.src.base : config.src.html;
|
|
1625
|
-
const patterns = [
|
|
1724
|
+
const patterns = [import_node_path13.default.join(templateDir, "*.html")];
|
|
1626
1725
|
if (config.pwa.manifest) {
|
|
1627
|
-
const manifestPattern =
|
|
1628
|
-
if ((0, import_node_fs4.existsSync)(
|
|
1726
|
+
const manifestPattern = import_node_path13.default.join(templateDir, config.pwa.manifest);
|
|
1727
|
+
if ((0, import_node_fs4.existsSync)(import_node_path13.default.isAbsolute(manifestPattern) ? manifestPattern : import_node_path13.default.join(config.workspace, manifestPattern))) {
|
|
1629
1728
|
patterns.push(manifestPattern);
|
|
1630
1729
|
}
|
|
1631
1730
|
}
|
|
@@ -1642,67 +1741,10 @@ var HtmlTask = class extends BaseTask {
|
|
|
1642
1741
|
return file2;
|
|
1643
1742
|
});
|
|
1644
1743
|
}
|
|
1645
|
-
if (config
|
|
1744
|
+
if (shouldUseTargetPaths(config)) {
|
|
1646
1745
|
pipeline.pipe(async (file2) => {
|
|
1647
|
-
if (/\.html$/i.test(file2.extname)) {
|
|
1648
|
-
|
|
1649
|
-
if (config.paths.source.css && config.paths.target.css && config.paths.source.css !== config.paths.target.css) {
|
|
1650
|
-
content = content.replaceAll(
|
|
1651
|
-
`/${config.paths.source.css}/`,
|
|
1652
|
-
`/${config.paths.target.css}/`
|
|
1653
|
-
);
|
|
1654
|
-
content = content.replaceAll(
|
|
1655
|
-
`"${config.paths.source.css}/`,
|
|
1656
|
-
`"${config.paths.target.css}/`
|
|
1657
|
-
);
|
|
1658
|
-
content = content.replaceAll(
|
|
1659
|
-
`'${config.paths.source.css}/`,
|
|
1660
|
-
`'${config.paths.target.css}/`
|
|
1661
|
-
);
|
|
1662
|
-
}
|
|
1663
|
-
if (config.paths.source.js && config.paths.target.js && config.paths.source.js !== config.paths.target.js) {
|
|
1664
|
-
content = content.replaceAll(
|
|
1665
|
-
`/${config.paths.source.js}/`,
|
|
1666
|
-
`/${config.paths.target.js}/`
|
|
1667
|
-
);
|
|
1668
|
-
content = content.replaceAll(
|
|
1669
|
-
`"${config.paths.source.js}/`,
|
|
1670
|
-
`"${config.paths.target.js}/`
|
|
1671
|
-
);
|
|
1672
|
-
content = content.replaceAll(
|
|
1673
|
-
`'${config.paths.source.js}/`,
|
|
1674
|
-
`'${config.paths.target.js}/`
|
|
1675
|
-
);
|
|
1676
|
-
}
|
|
1677
|
-
if (config.paths.source.img && config.paths.target.img && config.paths.source.img !== config.paths.target.img) {
|
|
1678
|
-
content = content.replaceAll(
|
|
1679
|
-
`/${config.paths.source.img}/`,
|
|
1680
|
-
`/${config.paths.target.img}/`
|
|
1681
|
-
);
|
|
1682
|
-
content = content.replaceAll(
|
|
1683
|
-
`"${config.paths.source.img}/`,
|
|
1684
|
-
`"${config.paths.target.img}/`
|
|
1685
|
-
);
|
|
1686
|
-
content = content.replaceAll(
|
|
1687
|
-
`'${config.paths.source.img}/`,
|
|
1688
|
-
`'${config.paths.target.img}/`
|
|
1689
|
-
);
|
|
1690
|
-
}
|
|
1691
|
-
if (config.paths.source.font && config.paths.target.font && config.paths.source.font !== config.paths.target.font) {
|
|
1692
|
-
content = content.replaceAll(
|
|
1693
|
-
`/${config.paths.source.font}/`,
|
|
1694
|
-
`/${config.paths.target.font}/`
|
|
1695
|
-
);
|
|
1696
|
-
content = content.replaceAll(
|
|
1697
|
-
`"${config.paths.source.font}/`,
|
|
1698
|
-
`"${config.paths.target.font}/`
|
|
1699
|
-
);
|
|
1700
|
-
content = content.replaceAll(
|
|
1701
|
-
`'${config.paths.source.font}/`,
|
|
1702
|
-
`'${config.paths.target.font}/`
|
|
1703
|
-
);
|
|
1704
|
-
}
|
|
1705
|
-
file2.contents = Buffer.from(content);
|
|
1746
|
+
if (/\.html$/i.test(file2.extname) || isManifestFile(file2, config)) {
|
|
1747
|
+
file2.contents = Buffer.from(rewriteHtmlAssetPaths(file2.toString(), config));
|
|
1706
1748
|
}
|
|
1707
1749
|
return file2;
|
|
1708
1750
|
});
|
|
@@ -1723,7 +1765,7 @@ var HtmlTask = class extends BaseTask {
|
|
|
1723
1765
|
)
|
|
1724
1766
|
).map((entryName) => {
|
|
1725
1767
|
let actualFilename = `${entryName}.js`;
|
|
1726
|
-
const hasUnhashed = (0, import_node_fs4.existsSync)(
|
|
1768
|
+
const hasUnhashed = (0, import_node_fs4.existsSync)(import_node_path13.default.join(destJsFolder, actualFilename));
|
|
1727
1769
|
let found = hasUnhashed;
|
|
1728
1770
|
try {
|
|
1729
1771
|
const matched = import_fast_glob3.default.sync(`${entryName}.*.js`, { cwd: destJsFolder });
|
|
@@ -1822,36 +1864,36 @@ ${LIVE_RELOAD_SCRIPT}`;
|
|
|
1822
1864
|
};
|
|
1823
1865
|
|
|
1824
1866
|
// src/tasks/copy.ts
|
|
1825
|
-
var
|
|
1867
|
+
var import_node_path15 = __toESM(require("path"), 1);
|
|
1826
1868
|
|
|
1827
1869
|
// src/pipeline/transforms/rename.ts
|
|
1828
|
-
var
|
|
1870
|
+
var import_node_path14 = __toESM(require("path"), 1);
|
|
1829
1871
|
function transformRename(options = {}) {
|
|
1830
1872
|
return async (file2) => {
|
|
1831
1873
|
if (typeof options === "string") {
|
|
1832
|
-
file2.path =
|
|
1874
|
+
file2.path = import_node_path14.default.resolve(import_node_path14.default.dirname(file2.path), options);
|
|
1833
1875
|
return file2;
|
|
1834
1876
|
}
|
|
1835
1877
|
if (typeof options === "function") {
|
|
1836
1878
|
const parsed = {
|
|
1837
|
-
dirname:
|
|
1879
|
+
dirname: import_node_path14.default.dirname(file2.path),
|
|
1838
1880
|
basename: file2.stem,
|
|
1839
1881
|
extname: file2.extname
|
|
1840
1882
|
};
|
|
1841
1883
|
const result = options(parsed);
|
|
1842
1884
|
if (result) {
|
|
1843
|
-
if (result.dirname) file2.path =
|
|
1885
|
+
if (result.dirname) file2.path = import_node_path14.default.join(result.dirname, import_node_path14.default.basename(file2.path));
|
|
1844
1886
|
if (result.basename) file2.stem = result.basename;
|
|
1845
1887
|
if (result.extname) file2.extname = result.extname;
|
|
1846
1888
|
}
|
|
1847
1889
|
return file2;
|
|
1848
1890
|
}
|
|
1849
1891
|
const { dirname, prefix = "", basename, suffix = "", extname } = options;
|
|
1850
|
-
const currentDir = dirname ?
|
|
1892
|
+
const currentDir = dirname ? import_node_path14.default.resolve(file2.cwd, dirname) : import_node_path14.default.dirname(file2.path);
|
|
1851
1893
|
const base = basename !== void 0 ? basename : file2.stem;
|
|
1852
1894
|
const ext = extname !== void 0 ? extname : file2.extname;
|
|
1853
1895
|
const dotExt = ext ? ext.startsWith(".") ? ext : `.${ext}` : "";
|
|
1854
|
-
file2.path =
|
|
1896
|
+
file2.path = import_node_path14.default.join(currentDir, `${prefix}${base}${suffix}${dotExt}`);
|
|
1855
1897
|
return file2;
|
|
1856
1898
|
};
|
|
1857
1899
|
}
|
|
@@ -1870,13 +1912,13 @@ var CopyTask = class extends BaseTask {
|
|
|
1870
1912
|
if (this.options.rename) {
|
|
1871
1913
|
pipeline.pipe(transformRename(this.options.rename));
|
|
1872
1914
|
}
|
|
1873
|
-
const outDir =
|
|
1915
|
+
const outDir = import_node_path15.default.isAbsolute(this.options.output) ? this.options.output : import_node_path15.default.join(config.workspace, this.options.output);
|
|
1874
1916
|
await pipeline.dest(outDir);
|
|
1875
1917
|
}
|
|
1876
1918
|
};
|
|
1877
1919
|
|
|
1878
1920
|
// src/tasks/remove.ts
|
|
1879
|
-
var
|
|
1921
|
+
var import_node_path16 = __toESM(require("path"), 1);
|
|
1880
1922
|
var RemoveTask = class extends BaseTask {
|
|
1881
1923
|
target;
|
|
1882
1924
|
constructor(target) {
|
|
@@ -1886,7 +1928,7 @@ var RemoveTask = class extends BaseTask {
|
|
|
1886
1928
|
async run(config) {
|
|
1887
1929
|
const targets = Array.isArray(this.target) ? this.target : [this.target];
|
|
1888
1930
|
const resolvedTargets = targets.map(
|
|
1889
|
-
(t) =>
|
|
1931
|
+
(t) => import_node_path16.default.isAbsolute(t) ? t : import_node_path16.default.join(config.workspace, t)
|
|
1890
1932
|
);
|
|
1891
1933
|
const deleted = await file.remove(resolvedTargets);
|
|
1892
1934
|
logger.warn("remove", `Removed: ${deleted.join(", ")}`);
|
|
@@ -1894,7 +1936,7 @@ var RemoveTask = class extends BaseTask {
|
|
|
1894
1936
|
};
|
|
1895
1937
|
|
|
1896
1938
|
// src/tasks/replace.ts
|
|
1897
|
-
var
|
|
1939
|
+
var import_node_path17 = __toESM(require("path"), 1);
|
|
1898
1940
|
var ReplaceTask = class extends BaseTask {
|
|
1899
1941
|
taskOptions;
|
|
1900
1942
|
constructor(taskOptions) {
|
|
@@ -1906,7 +1948,7 @@ var ReplaceTask = class extends BaseTask {
|
|
|
1906
1948
|
cwd: config.workspace
|
|
1907
1949
|
});
|
|
1908
1950
|
pipeline.pipe(transformReplace(this.taskOptions.options));
|
|
1909
|
-
const outDir =
|
|
1951
|
+
const outDir = import_node_path17.default.isAbsolute(this.taskOptions.output) ? this.taskOptions.output : import_node_path17.default.join(config.workspace, this.taskOptions.output);
|
|
1910
1952
|
await pipeline.dest(outDir);
|
|
1911
1953
|
}
|
|
1912
1954
|
};
|
|
@@ -1916,12 +1958,12 @@ var import_fast_glob4 = __toESM(require("fast-glob"), 1);
|
|
|
1916
1958
|
var import_promises3 = __toESM(require("fs/promises"), 1);
|
|
1917
1959
|
|
|
1918
1960
|
// src/pipeline/transforms/cache.ts
|
|
1919
|
-
var
|
|
1961
|
+
var import_node_path18 = __toESM(require("path"), 1);
|
|
1920
1962
|
var import_picomatch = __toESM(require("picomatch"), 1);
|
|
1921
1963
|
function matchesAny(filePath, rules) {
|
|
1922
1964
|
if (!rules || !rules.length) return false;
|
|
1923
1965
|
const normalized = filePath.replace(/\\/g, "/");
|
|
1924
|
-
const baseName =
|
|
1966
|
+
const baseName = import_node_path18.default.basename(normalized);
|
|
1925
1967
|
for (const rawRule of rules) {
|
|
1926
1968
|
if (typeof rawRule === "string") {
|
|
1927
1969
|
const rule = rawRule.replace(/\\/g, "/");
|
|
@@ -1975,9 +2017,9 @@ var AssetRevisioner = class {
|
|
|
1975
2017
|
const shouldRename = !alreadyHashed && !matchesAny(file2.path, this.options.dontRenameFile) && !matchesAny(file2.relative, this.options.dontRenameFile);
|
|
1976
2018
|
if (shouldRename) {
|
|
1977
2019
|
const fileHash = file.hash(file2.contents, hashLength);
|
|
1978
|
-
const dir =
|
|
2020
|
+
const dir = import_node_path18.default.dirname(file2.path);
|
|
1979
2021
|
const newFilename = `${file2.stem}.${fileHash}${file2.extname}`;
|
|
1980
|
-
file2.path =
|
|
2022
|
+
file2.path = import_node_path18.default.join(dir, newFilename);
|
|
1981
2023
|
}
|
|
1982
2024
|
if (alreadyHashed) {
|
|
1983
2025
|
const unhashedRelative = file2.relative.replace(/\.[a-f0-9]{8}(\.[^.]+)$/i, "$1");
|
|
@@ -1993,8 +2035,8 @@ var AssetRevisioner = class {
|
|
|
1993
2035
|
let content = file2.toString();
|
|
1994
2036
|
for (const [orig, reved] of manifestEntries) {
|
|
1995
2037
|
content = content.replaceAll(orig, reved);
|
|
1996
|
-
const origBase =
|
|
1997
|
-
const revedBase =
|
|
2038
|
+
const origBase = import_node_path18.default.basename(orig);
|
|
2039
|
+
const revedBase = import_node_path18.default.basename(reved);
|
|
1998
2040
|
const escapedBase = origBase.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1999
2041
|
const baseRegex = new RegExp(`${escapedBase}(?![a-zA-Z0-9_])`, "g");
|
|
2000
2042
|
content = content.replace(baseRegex, revedBase);
|
|
@@ -2007,7 +2049,7 @@ var AssetRevisioner = class {
|
|
|
2007
2049
|
const manifestFile = new VirtualFile({
|
|
2008
2050
|
cwd: files[0]?.cwd || process.cwd(),
|
|
2009
2051
|
base: firstBase,
|
|
2010
|
-
path:
|
|
2052
|
+
path: import_node_path18.default.join(firstBase, manifestName),
|
|
2011
2053
|
contents: JSON.stringify(this.manifest, null, 2)
|
|
2012
2054
|
});
|
|
2013
2055
|
outputFiles.push(manifestFile);
|
|
@@ -2083,7 +2125,7 @@ var CacheTask = class extends BaseTask {
|
|
|
2083
2125
|
};
|
|
2084
2126
|
|
|
2085
2127
|
// src/tasks/publish.ts
|
|
2086
|
-
var
|
|
2128
|
+
var import_node_path19 = __toESM(require("path"), 1);
|
|
2087
2129
|
var PublishTask = class extends BaseTask {
|
|
2088
2130
|
options;
|
|
2089
2131
|
constructor(options = {}) {
|
|
@@ -2104,17 +2146,17 @@ var PublishTask = class extends BaseTask {
|
|
|
2104
2146
|
await this.publishItem(config, input, output, renameOptions);
|
|
2105
2147
|
} else {
|
|
2106
2148
|
const srcDir = config.dest.base;
|
|
2107
|
-
const targetDir = config.assets.static ||
|
|
2149
|
+
const targetDir = config.assets.static || import_node_path19.default.join(config.assets.root, config.assets.mainDir);
|
|
2108
2150
|
const pipeline = Pipeline.from(["**/*"], {
|
|
2109
2151
|
cwd: srcDir,
|
|
2110
2152
|
base: srcDir
|
|
2111
2153
|
});
|
|
2112
|
-
await pipeline.dest(
|
|
2154
|
+
await pipeline.dest(import_node_path19.default.resolve(config.workspace, targetDir));
|
|
2113
2155
|
}
|
|
2114
2156
|
}
|
|
2115
2157
|
async publishItem(config, input, output, rename) {
|
|
2116
|
-
const srcPath =
|
|
2117
|
-
const destDir =
|
|
2158
|
+
const srcPath = import_node_path19.default.isAbsolute(input) ? input : import_node_path19.default.join(config.dest.base, input);
|
|
2159
|
+
const destDir = import_node_path19.default.isAbsolute(output) ? output : import_node_path19.default.join(config.workspace, config.assets.root, output);
|
|
2118
2160
|
const pipeline = Pipeline.from(srcPath, {
|
|
2119
2161
|
cwd: config.dest.base
|
|
2120
2162
|
});
|
|
@@ -2126,7 +2168,7 @@ var PublishTask = class extends BaseTask {
|
|
|
2126
2168
|
};
|
|
2127
2169
|
|
|
2128
2170
|
// src/tasks/pwa.ts
|
|
2129
|
-
var
|
|
2171
|
+
var import_node_path20 = __toESM(require("path"), 1);
|
|
2130
2172
|
var import_promises4 = __toESM(require("fs/promises"), 1);
|
|
2131
2173
|
var import_node_fs5 = require("fs");
|
|
2132
2174
|
var import_node_module2 = require("module");
|
|
@@ -2139,12 +2181,12 @@ var PwaTask = class extends BaseTask {
|
|
|
2139
2181
|
}
|
|
2140
2182
|
async run(config) {
|
|
2141
2183
|
const globDirectory = config.dest.base;
|
|
2142
|
-
const swDest =
|
|
2143
|
-
const swSrc =
|
|
2184
|
+
const swDest = import_node_path20.default.join(globDirectory, config.pwa.swDestFilename);
|
|
2185
|
+
const swSrc = import_node_path20.default.join(config.src.base, config.pwa.swSrcFilename);
|
|
2144
2186
|
const require2 = (0, import_node_module2.createRequire)(importMetaUrl);
|
|
2145
2187
|
const candidatePaths = [
|
|
2146
|
-
|
|
2147
|
-
|
|
2188
|
+
import_node_path20.default.join(config.workspace, "node_modules/workbox-sw/build/workbox-sw.js"),
|
|
2189
|
+
import_node_path20.default.join(config.workspace, "node_modules/workbox-sw/controllers/WorkboxSW.mjs")
|
|
2148
2190
|
];
|
|
2149
2191
|
try {
|
|
2150
2192
|
const resolved = require2.resolve("workbox-sw/build/workbox-sw.js");
|
|
@@ -2153,12 +2195,12 @@ var PwaTask = class extends BaseTask {
|
|
|
2153
2195
|
}
|
|
2154
2196
|
try {
|
|
2155
2197
|
const resolvedPkg = require2.resolve("workbox-sw");
|
|
2156
|
-
candidatePaths.push(
|
|
2198
|
+
candidatePaths.push(import_node_path20.default.join(import_node_path20.default.dirname(resolvedPkg), "build/workbox-sw.js"));
|
|
2157
2199
|
} catch {
|
|
2158
2200
|
}
|
|
2159
2201
|
for (const p of candidatePaths) {
|
|
2160
2202
|
if ((0, import_node_fs5.existsSync)(p)) {
|
|
2161
|
-
const destFile =
|
|
2203
|
+
const destFile = import_node_path20.default.join(globDirectory, "workbox-sw.js");
|
|
2162
2204
|
await import_promises4.default.copyFile(p, destFile);
|
|
2163
2205
|
break;
|
|
2164
2206
|
}
|
|
@@ -2194,7 +2236,7 @@ var PwaTask = class extends BaseTask {
|
|
|
2194
2236
|
|
|
2195
2237
|
// src/tasks/zip.ts
|
|
2196
2238
|
var import_node_fs6 = __toESM(require("fs"), 1);
|
|
2197
|
-
var
|
|
2239
|
+
var import_node_path21 = __toESM(require("path"), 1);
|
|
2198
2240
|
var import_archiver = __toESM(require("archiver"), 1);
|
|
2199
2241
|
var import_fast_glob5 = __toESM(require("fast-glob"), 1);
|
|
2200
2242
|
var ZipTask = class extends BaseTask {
|
|
@@ -2205,9 +2247,9 @@ var ZipTask = class extends BaseTask {
|
|
|
2205
2247
|
}
|
|
2206
2248
|
async run(config) {
|
|
2207
2249
|
const input = this.options.input || config.dest.base;
|
|
2208
|
-
const outputDir = this.options.output ?
|
|
2250
|
+
const outputDir = this.options.output ? import_node_path21.default.isAbsolute(this.options.output) ? this.options.output : import_node_path21.default.join(config.workspace, this.options.output) : config.workspace;
|
|
2209
2251
|
const filename = this.options.filename || "archive.zip";
|
|
2210
|
-
const zipPath =
|
|
2252
|
+
const zipPath = import_node_path21.default.join(outputDir, filename);
|
|
2211
2253
|
await file.ensureDir(outputDir);
|
|
2212
2254
|
return new Promise((resolve, reject) => {
|
|
2213
2255
|
const outputStream = import_node_fs6.default.createWriteStream(zipPath);
|
|
@@ -2228,18 +2270,18 @@ var ZipTask = class extends BaseTask {
|
|
|
2228
2270
|
const base = item.split("*")[0].replace(/\/+$/, "") || ".";
|
|
2229
2271
|
const matched = import_fast_glob5.default.sync(item, { cwd: config.workspace, onlyFiles: true, dot: true });
|
|
2230
2272
|
for (const relPath of matched) {
|
|
2231
|
-
const fullFilePath =
|
|
2232
|
-
const zipName =
|
|
2273
|
+
const fullFilePath = import_node_path21.default.join(config.workspace, relPath);
|
|
2274
|
+
const zipName = import_node_path21.default.relative(base, relPath);
|
|
2233
2275
|
archive.file(fullFilePath, { name: zipName });
|
|
2234
2276
|
}
|
|
2235
2277
|
} else {
|
|
2236
|
-
const fullPath =
|
|
2278
|
+
const fullPath = import_node_path21.default.isAbsolute(item) ? item : import_node_path21.default.join(config.workspace, item);
|
|
2237
2279
|
if (import_node_fs6.default.existsSync(fullPath)) {
|
|
2238
2280
|
const stat = import_node_fs6.default.statSync(fullPath);
|
|
2239
2281
|
if (stat.isDirectory()) {
|
|
2240
2282
|
archive.directory(fullPath, false);
|
|
2241
2283
|
} else {
|
|
2242
|
-
archive.file(fullPath, { name:
|
|
2284
|
+
archive.file(fullPath, { name: import_node_path21.default.basename(fullPath) });
|
|
2243
2285
|
}
|
|
2244
2286
|
}
|
|
2245
2287
|
}
|
|
@@ -2250,7 +2292,7 @@ var ZipTask = class extends BaseTask {
|
|
|
2250
2292
|
};
|
|
2251
2293
|
|
|
2252
2294
|
// src/tasks/ftp.ts
|
|
2253
|
-
var
|
|
2295
|
+
var import_node_path22 = __toESM(require("path"), 1);
|
|
2254
2296
|
var import_ssh2 = require("ssh2");
|
|
2255
2297
|
var import_fast_glob6 = __toESM(require("fast-glob"), 1);
|
|
2256
2298
|
var FtpTask = class extends BaseTask {
|
|
@@ -2286,8 +2328,8 @@ var FtpTask = class extends BaseTask {
|
|
|
2286
2328
|
}
|
|
2287
2329
|
let pending = files.length;
|
|
2288
2330
|
for (const file2 of files) {
|
|
2289
|
-
const rel =
|
|
2290
|
-
const remoteFile =
|
|
2331
|
+
const rel = import_node_path22.default.relative(config.workspace, file2);
|
|
2332
|
+
const remoteFile = import_node_path22.default.posix.join(options.remotePath, rel);
|
|
2291
2333
|
sftp.fastPut(file2, remoteFile, (putErr) => {
|
|
2292
2334
|
if (putErr) {
|
|
2293
2335
|
logger.error("ftp", `Failed uploading ${file2}: ${putErr.message}`);
|
|
@@ -2315,7 +2357,7 @@ var FtpTask = class extends BaseTask {
|
|
|
2315
2357
|
// src/tasks/server.ts
|
|
2316
2358
|
var import_node_http = __toESM(require("http"), 1);
|
|
2317
2359
|
var import_node_fs8 = __toESM(require("fs"), 1);
|
|
2318
|
-
var
|
|
2360
|
+
var import_node_path24 = __toESM(require("path"), 1);
|
|
2319
2361
|
var import_connect = __toESM(require("connect"), 1);
|
|
2320
2362
|
var import_serve_static = __toESM(require("serve-static"), 1);
|
|
2321
2363
|
var import_ws = require("ws");
|
|
@@ -2323,7 +2365,7 @@ var import_http_proxy_middleware = require("http-proxy-middleware");
|
|
|
2323
2365
|
|
|
2324
2366
|
// src/watcher/index.ts
|
|
2325
2367
|
var import_node_fs7 = __toESM(require("fs"), 1);
|
|
2326
|
-
var
|
|
2368
|
+
var import_node_path23 = __toESM(require("path"), 1);
|
|
2327
2369
|
var import_picocolors3 = __toESM(require("picocolors"), 1);
|
|
2328
2370
|
var FileWatcher = class {
|
|
2329
2371
|
config;
|
|
@@ -2348,10 +2390,10 @@ var FileWatcher = class {
|
|
|
2348
2390
|
...this.config.scripts.includeJsResource || [],
|
|
2349
2391
|
...this.config.styles.atImportPaths || []
|
|
2350
2392
|
];
|
|
2351
|
-
const resolved = candidates.filter(Boolean).map((dir) =>
|
|
2393
|
+
const resolved = candidates.filter(Boolean).map((dir) => import_node_path23.default.isAbsolute(dir) ? dir : import_node_path23.default.resolve(this.config.workspace, dir)).filter((dir) => import_node_fs7.default.existsSync(dir) && !dir.includes(`${import_node_path23.default.sep}node_modules`));
|
|
2352
2394
|
const unique = Array.from(new Set(resolved)).sort((a, b) => a.length - b.length);
|
|
2353
2395
|
return unique.filter(
|
|
2354
|
-
(dir, index) => !unique.slice(0, index).some((parent) => dir.startsWith(`${parent}${
|
|
2396
|
+
(dir, index) => !unique.slice(0, index).some((parent) => dir.startsWith(`${parent}${import_node_path23.default.sep}`))
|
|
2355
2397
|
);
|
|
2356
2398
|
}
|
|
2357
2399
|
start() {
|
|
@@ -2469,9 +2511,9 @@ var ServerTask = class extends BaseTask {
|
|
|
2469
2511
|
app.use((req, res, next) => {
|
|
2470
2512
|
if (req.url === "/manifest.json" || req.url?.endsWith("/manifest.json")) {
|
|
2471
2513
|
const candidates = [
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2514
|
+
import_node_path24.default.join(config.dest.base, "manifest.json"),
|
|
2515
|
+
import_node_path24.default.join(config.src.base, "manifest.json"),
|
|
2516
|
+
import_node_path24.default.join(config.workspace, "manifest.json")
|
|
2475
2517
|
];
|
|
2476
2518
|
const file2 = candidates.find((f) => import_node_fs8.default.existsSync(f));
|
|
2477
2519
|
if (file2) {
|
|
@@ -2496,37 +2538,37 @@ var ServerTask = class extends BaseTask {
|
|
|
2496
2538
|
if (config.paths.tmp.js && config.paths.tmp.js !== config.paths.source.js) {
|
|
2497
2539
|
app.use("/" + config.paths.tmp.js, (0, import_serve_static.default)(config.dest.js));
|
|
2498
2540
|
}
|
|
2499
|
-
app.use("/chunk", (0, import_serve_static.default)(
|
|
2500
|
-
app.use("/chunk", (0, import_serve_static.default)(
|
|
2541
|
+
app.use("/chunk", (0, import_serve_static.default)(import_node_path24.default.join(config.dest.js, "chunk")));
|
|
2542
|
+
app.use("/chunk", (0, import_serve_static.default)(import_node_path24.default.join(config.dest.base, "chunk")));
|
|
2501
2543
|
if (config.paths.source.img) {
|
|
2502
2544
|
app.use(
|
|
2503
2545
|
"/" + config.paths.source.img,
|
|
2504
|
-
(0, import_serve_static.default)(
|
|
2546
|
+
(0, import_serve_static.default)(import_node_path24.default.join(config.src.base, config.paths.source.img))
|
|
2505
2547
|
);
|
|
2506
2548
|
}
|
|
2507
2549
|
if (config.paths.tmp.img) {
|
|
2508
2550
|
app.use("/" + config.paths.tmp.img, (0, import_serve_static.default)(config.dest.img));
|
|
2509
2551
|
}
|
|
2510
|
-
app.use("/img", (0, import_serve_static.default)(
|
|
2511
|
-
app.use("/img", (0, import_serve_static.default)(
|
|
2552
|
+
app.use("/img", (0, import_serve_static.default)(import_node_path24.default.join(config.dest.base, "img")));
|
|
2553
|
+
app.use("/img", (0, import_serve_static.default)(import_node_path24.default.join(config.dest.js, "img")));
|
|
2512
2554
|
if (config.paths.source.font) {
|
|
2513
2555
|
app.use(
|
|
2514
2556
|
"/" + config.paths.source.font,
|
|
2515
|
-
(0, import_serve_static.default)(
|
|
2557
|
+
(0, import_serve_static.default)(import_node_path24.default.join(config.src.base, config.paths.source.font))
|
|
2516
2558
|
);
|
|
2517
2559
|
}
|
|
2518
2560
|
if (config.paths.tmp.font) {
|
|
2519
2561
|
app.use("/" + config.paths.tmp.font, (0, import_serve_static.default)(config.dest.font));
|
|
2520
2562
|
}
|
|
2521
|
-
app.use("/font", (0, import_serve_static.default)(
|
|
2522
|
-
app.use("/font", (0, import_serve_static.default)(
|
|
2523
|
-
app.use("/fonts", (0, import_serve_static.default)(
|
|
2524
|
-
app.use("/fonts", (0, import_serve_static.default)(
|
|
2563
|
+
app.use("/font", (0, import_serve_static.default)(import_node_path24.default.join(config.dest.base, "font")));
|
|
2564
|
+
app.use("/font", (0, import_serve_static.default)(import_node_path24.default.join(config.dest.js, "font")));
|
|
2565
|
+
app.use("/fonts", (0, import_serve_static.default)(import_node_path24.default.join(config.src.base, "fonts")));
|
|
2566
|
+
app.use("/fonts", (0, import_serve_static.default)(import_node_path24.default.join(config.dest.base, "fonts")));
|
|
2525
2567
|
if (config.server.serveStatic) {
|
|
2526
2568
|
const staticEntries = Array.isArray(config.server.serveStatic) ? config.server.serveStatic : [config.server.serveStatic];
|
|
2527
2569
|
for (const entry of staticEntries) {
|
|
2528
2570
|
if (typeof entry === "string") {
|
|
2529
|
-
const absoluteDir =
|
|
2571
|
+
const absoluteDir = import_node_path24.default.isAbsolute(entry) ? entry : import_node_path24.default.join(config.workspace, entry);
|
|
2530
2572
|
if (import_node_fs8.default.existsSync(absoluteDir)) {
|
|
2531
2573
|
app.use((0, import_serve_static.default)(absoluteDir));
|
|
2532
2574
|
}
|
|
@@ -2534,7 +2576,7 @@ var ServerTask = class extends BaseTask {
|
|
|
2534
2576
|
const route = entry.route ? entry.route.startsWith("/") ? entry.route : `/${entry.route}` : "";
|
|
2535
2577
|
const dirs = Array.isArray(entry.dir) ? entry.dir : [entry.dir];
|
|
2536
2578
|
for (const dir of dirs) {
|
|
2537
|
-
const absoluteDir =
|
|
2579
|
+
const absoluteDir = import_node_path24.default.isAbsolute(dir) ? dir : import_node_path24.default.join(config.workspace, dir);
|
|
2538
2580
|
if (import_node_fs8.default.existsSync(absoluteDir)) {
|
|
2539
2581
|
if (route) {
|
|
2540
2582
|
app.use(route, (0, import_serve_static.default)(absoluteDir));
|
|
@@ -2554,8 +2596,8 @@ var ServerTask = class extends BaseTask {
|
|
|
2554
2596
|
const isGetOrHead = req.method === "GET" || req.method === "HEAD";
|
|
2555
2597
|
const isHtmlNav = !req.url?.includes(".") || req.headers.accept?.includes("text/html");
|
|
2556
2598
|
if (isGetOrHead && isHtmlNav) {
|
|
2557
|
-
const indexPath =
|
|
2558
|
-
const srcIndexPath =
|
|
2599
|
+
const indexPath = import_node_path24.default.join(config.dest.html, "index.html");
|
|
2600
|
+
const srcIndexPath = import_node_path24.default.join(config.src.base, "index.html");
|
|
2559
2601
|
const fileToServe = import_node_fs8.default.existsSync(indexPath) ? indexPath : srcIndexPath;
|
|
2560
2602
|
if (import_node_fs8.default.existsSync(fileToServe)) {
|
|
2561
2603
|
res.setHeader("Content-Type", "text/html; charset=utf-8");
|
|
@@ -2605,7 +2647,7 @@ var ServerTask = class extends BaseTask {
|
|
|
2605
2647
|
};
|
|
2606
2648
|
|
|
2607
2649
|
// src/tasks/static.ts
|
|
2608
|
-
var
|
|
2650
|
+
var import_node_path25 = __toESM(require("path"), 1);
|
|
2609
2651
|
var import_node_fs9 = require("fs");
|
|
2610
2652
|
var StaticTask = class extends BaseTask {
|
|
2611
2653
|
constructor() {
|
|
@@ -2615,8 +2657,8 @@ var StaticTask = class extends BaseTask {
|
|
|
2615
2657
|
const srcBase = config.src.base;
|
|
2616
2658
|
const destBase = config.dest.base;
|
|
2617
2659
|
const staticPatterns = [
|
|
2618
|
-
|
|
2619
|
-
`!${
|
|
2660
|
+
import_node_path25.default.join(srcBase, "*.{ico,png,svg,json,txt,xml,webmanifest}"),
|
|
2661
|
+
`!${import_node_path25.default.join(srcBase, "*.html")}`
|
|
2620
2662
|
];
|
|
2621
2663
|
const extraIncludes = [
|
|
2622
2664
|
...config.extras?.includes || [],
|
|
@@ -2627,11 +2669,11 @@ var StaticTask = class extends BaseTask {
|
|
|
2627
2669
|
...config.assets?.excludes || []
|
|
2628
2670
|
];
|
|
2629
2671
|
for (const inc of extraIncludes) {
|
|
2630
|
-
const pattern =
|
|
2672
|
+
const pattern = import_node_path25.default.isAbsolute(inc) ? inc : import_node_path25.default.join(srcBase, inc);
|
|
2631
2673
|
staticPatterns.push(pattern);
|
|
2632
2674
|
}
|
|
2633
2675
|
for (const exc of extraExcludes) {
|
|
2634
|
-
const pattern =
|
|
2676
|
+
const pattern = import_node_path25.default.isAbsolute(exc) ? exc : import_node_path25.default.join(srcBase, exc);
|
|
2635
2677
|
staticPatterns.push(`!${pattern}`);
|
|
2636
2678
|
}
|
|
2637
2679
|
const pipeline = Pipeline.from(staticPatterns, {
|
|
@@ -2640,38 +2682,42 @@ var StaticTask = class extends BaseTask {
|
|
|
2640
2682
|
});
|
|
2641
2683
|
const publicUrlReplacement = config.assets.virtualDir ? `/${config.assets.virtualDir}` : "";
|
|
2642
2684
|
pipeline.pipe(async (file2) => {
|
|
2643
|
-
|
|
2685
|
+
const isManifest = isManifestFile(file2, config);
|
|
2686
|
+
if (isManifest || file2.extname === ".json") {
|
|
2644
2687
|
let content = file2.toString();
|
|
2645
2688
|
content = content.replaceAll(PUBLIC_URL, publicUrlReplacement);
|
|
2689
|
+
if (isManifest) {
|
|
2690
|
+
content = rewriteHtmlAssetPaths(content, config);
|
|
2691
|
+
}
|
|
2646
2692
|
file2.contents = Buffer.from(content);
|
|
2647
2693
|
}
|
|
2648
2694
|
return file2;
|
|
2649
2695
|
});
|
|
2650
2696
|
await pipeline.dest(destBase);
|
|
2651
2697
|
if (config.src.img && (0, import_node_fs9.existsSync)(config.src.img)) {
|
|
2652
|
-
const imgPipeline = Pipeline.from(
|
|
2698
|
+
const imgPipeline = Pipeline.from(import_node_path25.default.join(config.src.img, "**/*"), {
|
|
2653
2699
|
cwd: config.workspace,
|
|
2654
2700
|
base: config.src.img
|
|
2655
2701
|
});
|
|
2656
2702
|
await imgPipeline.dest(config.dest.img);
|
|
2657
2703
|
}
|
|
2658
2704
|
if (config.src.font && (0, import_node_fs9.existsSync)(config.src.font)) {
|
|
2659
|
-
const fontPipeline = Pipeline.from(
|
|
2705
|
+
const fontPipeline = Pipeline.from(import_node_path25.default.join(config.src.font, "**/*"), {
|
|
2660
2706
|
cwd: config.workspace,
|
|
2661
2707
|
base: config.src.font
|
|
2662
2708
|
});
|
|
2663
2709
|
await fontPipeline.dest(config.dest.font);
|
|
2664
2710
|
}
|
|
2665
2711
|
if (config.src.media && (0, import_node_fs9.existsSync)(config.src.media)) {
|
|
2666
|
-
const mediaPipeline = Pipeline.from(
|
|
2712
|
+
const mediaPipeline = Pipeline.from(import_node_path25.default.join(config.src.media, "**/*"), {
|
|
2667
2713
|
cwd: config.workspace,
|
|
2668
2714
|
base: config.src.media
|
|
2669
2715
|
});
|
|
2670
2716
|
await mediaPipeline.dest(config.dest.media);
|
|
2671
2717
|
}
|
|
2672
|
-
const publicDir =
|
|
2718
|
+
const publicDir = import_node_path25.default.join(config.workspace, "public");
|
|
2673
2719
|
if ((0, import_node_fs9.existsSync)(publicDir)) {
|
|
2674
|
-
const pubPipeline = Pipeline.from(
|
|
2720
|
+
const pubPipeline = Pipeline.from(import_node_path25.default.join(publicDir, "**/*"), {
|
|
2675
2721
|
cwd: config.workspace,
|
|
2676
2722
|
base: publicDir
|
|
2677
2723
|
});
|
|
@@ -2974,6 +3020,7 @@ var index_default = balm;
|
|
|
2974
3020
|
isArray,
|
|
2975
3021
|
isBoolean,
|
|
2976
3022
|
isFunction,
|
|
3023
|
+
isManifestFile,
|
|
2977
3024
|
isObject,
|
|
2978
3025
|
isString,
|
|
2979
3026
|
localResolve,
|
|
@@ -2981,11 +3028,15 @@ var index_default = balm;
|
|
|
2981
3028
|
logger,
|
|
2982
3029
|
resolveConfig,
|
|
2983
3030
|
resolveDefaultEntry,
|
|
3031
|
+
rewriteCssAssetUrls,
|
|
3032
|
+
rewriteHtmlAssetPaths,
|
|
2984
3033
|
runEsbuild,
|
|
2985
3034
|
runRollup,
|
|
2986
3035
|
runWebpack,
|
|
2987
3036
|
setWorkspaces,
|
|
3037
|
+
shouldUseTargetPaths,
|
|
2988
3038
|
toNamespace,
|
|
3039
|
+
transformCssUrl,
|
|
2989
3040
|
transformHtmlmin,
|
|
2990
3041
|
transformLess,
|
|
2991
3042
|
transformPostcss,
|