@normed/bundle 4.5.1 → 4.5.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.
- package/CHANGELOG.md +8 -0
- package/bundles/bin/cli.js +69 -28
- package/bundles/bin/cli.js.map +3 -3
- package/bundles/index.js +69 -28
- package/bundles/index.js.map +3 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,14 @@ Given a version number MAJOR.MINOR.PATCH, increment the:
|
|
|
6
6
|
2. MINOR version when you add functionality in a backwards compatible manner, and
|
|
7
7
|
3. PATCH version when you make backwards compatible bug fixes.
|
|
8
8
|
|
|
9
|
+
# 4.5.3
|
|
10
|
+
|
|
11
|
+
* MINOR: Less files referenced from pug templates are now compiled to CSS. The `href` is rewritten to point to the compiled `.css` file with a content hash.
|
|
12
|
+
|
|
13
|
+
# 4.5.2
|
|
14
|
+
|
|
15
|
+
* PATCH: Fixes incorrect asset path resolution in pug templates when using custom `assetNames` configuration. Asset paths are now correctly computed relative to the HTML output location.
|
|
16
|
+
|
|
9
17
|
# 4.5.1
|
|
10
18
|
|
|
11
19
|
* PATCH: Fixes discovered pug files being output with `.pug` extension instead of `.html`.
|
package/bundles/bin/cli.js
CHANGED
|
@@ -25376,8 +25376,8 @@ var require_plugin_manager = __commonJS({
|
|
|
25376
25376
|
var PluginManager = (
|
|
25377
25377
|
/** @class */
|
|
25378
25378
|
function() {
|
|
25379
|
-
function PluginManager2(
|
|
25380
|
-
this.less =
|
|
25379
|
+
function PluginManager2(less3) {
|
|
25380
|
+
this.less = less3;
|
|
25381
25381
|
this.visitors = [];
|
|
25382
25382
|
this.preProcessors = [];
|
|
25383
25383
|
this.postProcessors = [];
|
|
@@ -25385,7 +25385,7 @@ var require_plugin_manager = __commonJS({
|
|
|
25385
25385
|
this.fileManagers = [];
|
|
25386
25386
|
this.iterator = -1;
|
|
25387
25387
|
this.pluginCache = {};
|
|
25388
|
-
this.Loader = new
|
|
25388
|
+
this.Loader = new less3.PluginLoader(less3);
|
|
25389
25389
|
}
|
|
25390
25390
|
PluginManager2.prototype.addPlugins = function(plugins) {
|
|
25391
25391
|
if (plugins) {
|
|
@@ -25467,9 +25467,9 @@ var require_plugin_manager = __commonJS({
|
|
|
25467
25467
|
}()
|
|
25468
25468
|
);
|
|
25469
25469
|
var pm;
|
|
25470
|
-
var PluginManagerFactory = function(
|
|
25470
|
+
var PluginManagerFactory = function(less3, newFactory) {
|
|
25471
25471
|
if (newFactory || !pm) {
|
|
25472
|
-
pm = new PluginManager(
|
|
25472
|
+
pm = new PluginManager(less3);
|
|
25473
25473
|
}
|
|
25474
25474
|
return pm;
|
|
25475
25475
|
};
|
|
@@ -25782,8 +25782,8 @@ var require_import_manager = __commonJS({
|
|
|
25782
25782
|
var ImportManager = (
|
|
25783
25783
|
/** @class */
|
|
25784
25784
|
function() {
|
|
25785
|
-
function ImportManager2(
|
|
25786
|
-
this.less =
|
|
25785
|
+
function ImportManager2(less3, context, rootFileInfo) {
|
|
25786
|
+
this.less = less3;
|
|
25787
25787
|
this.rootFilename = rootFileInfo.filename;
|
|
25788
25788
|
this.paths = context.paths || [];
|
|
25789
25789
|
this.contents = {};
|
|
@@ -26397,8 +26397,8 @@ var require_plugin_loader = __commonJS({
|
|
|
26397
26397
|
var tslib_1 = require_tslib();
|
|
26398
26398
|
var path_1 = tslib_1.__importDefault(require("path"));
|
|
26399
26399
|
var abstract_plugin_loader_js_1 = tslib_1.__importDefault(require_abstract_plugin_loader());
|
|
26400
|
-
var PluginLoader = function(
|
|
26401
|
-
this.less =
|
|
26400
|
+
var PluginLoader = function(less3) {
|
|
26401
|
+
this.less = less3;
|
|
26402
26402
|
this.require = function(prefix) {
|
|
26403
26403
|
prefix = path_1.default.dirname(prefix);
|
|
26404
26404
|
return function(id) {
|
|
@@ -27079,17 +27079,17 @@ var require_less_node = __commonJS({
|
|
|
27079
27079
|
var file_manager_1 = tslib_1.__importDefault(require_file_manager());
|
|
27080
27080
|
var url_file_manager_1 = tslib_1.__importDefault(require_url_file_manager());
|
|
27081
27081
|
var less_1 = tslib_1.__importDefault(require_less());
|
|
27082
|
-
var
|
|
27082
|
+
var less3 = (0, less_1.default)(environment_1.default, [new file_manager_1.default(), new url_file_manager_1.default()]);
|
|
27083
27083
|
var lessc_helper_1 = tslib_1.__importDefault(require_lessc_helper());
|
|
27084
|
-
|
|
27085
|
-
|
|
27086
|
-
|
|
27087
|
-
|
|
27088
|
-
|
|
27089
|
-
|
|
27090
|
-
|
|
27091
|
-
require_image_size().default(
|
|
27092
|
-
exports2.default =
|
|
27084
|
+
less3.createFromEnvironment = less_1.default;
|
|
27085
|
+
less3.lesscHelper = lessc_helper_1.default;
|
|
27086
|
+
less3.PluginLoader = require_plugin_loader().default;
|
|
27087
|
+
less3.fs = require_fs2().default;
|
|
27088
|
+
less3.FileManager = file_manager_1.default;
|
|
27089
|
+
less3.UrlFileManager = url_file_manager_1.default;
|
|
27090
|
+
less3.options = require_default_options().default();
|
|
27091
|
+
require_image_size().default(less3.environment);
|
|
27092
|
+
exports2.default = less3;
|
|
27093
27093
|
}
|
|
27094
27094
|
});
|
|
27095
27095
|
|
|
@@ -69136,11 +69136,25 @@ var import_pug = __toESM(require_lib14());
|
|
|
69136
69136
|
var import_fs4 = __toESM(require("fs"));
|
|
69137
69137
|
var import_path5 = __toESM(require("path"));
|
|
69138
69138
|
var import_crypto = __toESM(require("crypto"));
|
|
69139
|
+
var import_less2 = __toESM(require_less2());
|
|
69140
|
+
var less2 = import_less2.default;
|
|
69139
69141
|
function computeContentHash(content) {
|
|
69140
69142
|
const hash = import_crypto.default.createHash("sha256").update(content).digest();
|
|
69141
69143
|
const num = hash.readUInt32BE(0);
|
|
69142
69144
|
return num.toString(36).toUpperCase().padStart(8, "0").slice(0, 8);
|
|
69143
69145
|
}
|
|
69146
|
+
function isCompilableAsset(assetPath) {
|
|
69147
|
+
return assetPath.endsWith(".less");
|
|
69148
|
+
}
|
|
69149
|
+
async function compileLess(absoluteSource) {
|
|
69150
|
+
const fileData = await import_fs4.default.promises.readFile(absoluteSource, {
|
|
69151
|
+
encoding: "utf8"
|
|
69152
|
+
});
|
|
69153
|
+
const lessResult = await less2.render(fileData, {
|
|
69154
|
+
paths: [import_path5.default.dirname(absoluteSource)]
|
|
69155
|
+
});
|
|
69156
|
+
return { content: lessResult.css, outputExt: ".css" };
|
|
69157
|
+
}
|
|
69144
69158
|
var ASSET_ATTRIBUTES = {
|
|
69145
69159
|
img: ["src", "srcset"],
|
|
69146
69160
|
video: ["src", "poster"],
|
|
@@ -69226,6 +69240,7 @@ async function processHtmlAssets(html, pugFilePath, options2) {
|
|
|
69226
69240
|
const hashedPath = await processAsset(
|
|
69227
69241
|
assetPath,
|
|
69228
69242
|
pugDir,
|
|
69243
|
+
pugFilePath,
|
|
69229
69244
|
outdir,
|
|
69230
69245
|
outbase,
|
|
69231
69246
|
assetNames,
|
|
@@ -69255,6 +69270,7 @@ async function processHtmlAssets(html, pugFilePath, options2) {
|
|
|
69255
69270
|
const hashedPath = await processAsset(
|
|
69256
69271
|
value,
|
|
69257
69272
|
pugDir,
|
|
69273
|
+
pugFilePath,
|
|
69258
69274
|
outdir,
|
|
69259
69275
|
outbase,
|
|
69260
69276
|
assetNames,
|
|
@@ -69273,7 +69289,7 @@ async function processHtmlAssets(html, pugFilePath, options2) {
|
|
|
69273
69289
|
}
|
|
69274
69290
|
return { html: modifiedHtml, assets, pugReferences };
|
|
69275
69291
|
}
|
|
69276
|
-
async function processAsset(assetPath, pugDir, outdir, outbase, assetNames, publicPath, assets, processedAssets) {
|
|
69292
|
+
async function processAsset(assetPath, pugDir, pugFilePath, outdir, outbase, assetNames, publicPath, assets, processedAssets) {
|
|
69277
69293
|
const absoluteSource = import_path5.default.resolve(pugDir, assetPath);
|
|
69278
69294
|
if (processedAssets.has(absoluteSource)) {
|
|
69279
69295
|
return processedAssets.get(absoluteSource);
|
|
@@ -69282,21 +69298,40 @@ async function processAsset(assetPath, pugDir, outdir, outbase, assetNames, publ
|
|
|
69282
69298
|
return null;
|
|
69283
69299
|
}
|
|
69284
69300
|
try {
|
|
69285
|
-
|
|
69301
|
+
let content;
|
|
69302
|
+
let compiledContent;
|
|
69303
|
+
let outputAssetPath = assetPath;
|
|
69304
|
+
if (isCompilableAsset(assetPath)) {
|
|
69305
|
+
const compiled = await compileLess(absoluteSource);
|
|
69306
|
+
content = compiled.content;
|
|
69307
|
+
compiledContent = compiled.content;
|
|
69308
|
+
outputAssetPath = assetPath.replace(/\.less$/, compiled.outputExt);
|
|
69309
|
+
} else {
|
|
69310
|
+
content = await import_fs4.default.promises.readFile(absoluteSource);
|
|
69311
|
+
}
|
|
69286
69312
|
const hash = computeContentHash(content);
|
|
69287
69313
|
const hashedFilename = applyAssetNamesTemplate(
|
|
69288
69314
|
assetNames,
|
|
69289
|
-
|
|
69315
|
+
outputAssetPath,
|
|
69290
69316
|
hash,
|
|
69291
69317
|
outbase
|
|
69292
69318
|
);
|
|
69293
69319
|
const absoluteOutput = import_path5.default.join(outdir, hashedFilename);
|
|
69294
|
-
const
|
|
69320
|
+
const pugRelativeToOutbase = import_path5.default.relative(outbase, pugFilePath);
|
|
69321
|
+
const htmlOutputPath = import_path5.default.join(outdir, pugRelativeToOutbase);
|
|
69322
|
+
const htmlOutputDir = import_path5.default.dirname(htmlOutputPath);
|
|
69323
|
+
let htmlPath;
|
|
69324
|
+
if (publicPath) {
|
|
69325
|
+
htmlPath = publicPath.replace(/\/$/, "") + "/" + hashedFilename;
|
|
69326
|
+
} else {
|
|
69327
|
+
htmlPath = import_path5.default.relative(htmlOutputDir, absoluteOutput);
|
|
69328
|
+
}
|
|
69295
69329
|
assets.push({
|
|
69296
69330
|
originalPath: assetPath,
|
|
69297
69331
|
hashedPath: htmlPath,
|
|
69298
69332
|
absoluteSource,
|
|
69299
|
-
absoluteOutput
|
|
69333
|
+
absoluteOutput,
|
|
69334
|
+
compiledContent
|
|
69300
69335
|
});
|
|
69301
69336
|
processedAssets.set(absoluteSource, htmlPath);
|
|
69302
69337
|
return htmlPath;
|
|
@@ -69305,13 +69340,19 @@ async function processAsset(assetPath, pugDir, outdir, outbase, assetNames, publ
|
|
|
69305
69340
|
}
|
|
69306
69341
|
}
|
|
69307
69342
|
async function copyAssets(assets) {
|
|
69308
|
-
const
|
|
69343
|
+
const written = /* @__PURE__ */ new Set();
|
|
69309
69344
|
for (const asset of assets) {
|
|
69310
|
-
if (
|
|
69311
|
-
|
|
69345
|
+
if (written.has(asset.absoluteOutput)) continue;
|
|
69346
|
+
written.add(asset.absoluteOutput);
|
|
69312
69347
|
const outputDir = import_path5.default.dirname(asset.absoluteOutput);
|
|
69313
69348
|
await import_fs4.default.promises.mkdir(outputDir, { recursive: true });
|
|
69314
|
-
|
|
69349
|
+
if (asset.compiledContent !== void 0) {
|
|
69350
|
+
await import_fs4.default.promises.writeFile(asset.absoluteOutput, asset.compiledContent, {
|
|
69351
|
+
encoding: "utf8"
|
|
69352
|
+
});
|
|
69353
|
+
} else {
|
|
69354
|
+
await import_fs4.default.promises.copyFile(asset.absoluteSource, asset.absoluteOutput);
|
|
69355
|
+
}
|
|
69315
69356
|
}
|
|
69316
69357
|
}
|
|
69317
69358
|
var filters = {
|