@divriots/jampack 0.14.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compressors/images.js +2 -2
- package/dist/config-default.js +3 -0
- package/dist/config-fast.js +3 -0
- package/dist/config-types.d.ts +3 -0
- package/dist/config.js +1 -1
- package/dist/optimize.js +6 -4
- package/package.json +10 -10
|
@@ -19,8 +19,6 @@ export async function compressImage(data, options) {
|
|
|
19
19
|
}
|
|
20
20
|
// Load modifiable toFormat
|
|
21
21
|
let toFormat = options.toFormat || 'unchanged';
|
|
22
|
-
if (!config.image.compress)
|
|
23
|
-
return undefined;
|
|
24
22
|
let sharpFile = await sharp(data, { animated: true });
|
|
25
23
|
const meta = await sharpFile.metadata();
|
|
26
24
|
if (meta.pages && meta.pages > 1) {
|
|
@@ -30,6 +28,8 @@ export async function compressImage(data, options) {
|
|
|
30
28
|
let outputFormat;
|
|
31
29
|
// Special case for svg
|
|
32
30
|
if (meta.format === 'svg') {
|
|
31
|
+
if (!config.image.svg.optimization)
|
|
32
|
+
return undefined;
|
|
33
33
|
try {
|
|
34
34
|
const output = svgo(data.toString(), {
|
|
35
35
|
multipass: true,
|
package/dist/config-default.js
CHANGED
package/dist/config-fast.js
CHANGED
package/dist/config-types.d.ts
CHANGED
package/dist/config.js
CHANGED
|
@@ -10,7 +10,7 @@ export function fast() {
|
|
|
10
10
|
export async function loadConfig() {
|
|
11
11
|
const proload = await load('jampack', { mustExist: false });
|
|
12
12
|
if (proload) {
|
|
13
|
-
console.log('
|
|
13
|
+
console.log('Merging default config with:');
|
|
14
14
|
console.log(JSON.stringify(proload.value, null, 2));
|
|
15
15
|
Object.assign(options, deepmerge(options, proload.value));
|
|
16
16
|
}
|
package/dist/optimize.js
CHANGED
|
@@ -252,10 +252,12 @@ async function processImage(htmlfile, $, imgElement, isAboveTheFold) {
|
|
|
252
252
|
? 'unchanged'
|
|
253
253
|
: 'webp';
|
|
254
254
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
255
|
+
if (config.image.compress) {
|
|
256
|
+
newImage = await compressImage(await originalImage.getData(), {
|
|
257
|
+
toFormat: srcToFormat,
|
|
258
|
+
resize: { width: config.image.srcset_max_width },
|
|
259
|
+
});
|
|
260
|
+
}
|
|
259
261
|
if ((newImage === null || newImage === void 0 ? void 0 : newImage.data) &&
|
|
260
262
|
(newImage.data.length < (await originalImage.getLen()) ||
|
|
261
263
|
srcToFormat === 'jpeg+progressive') // Progressive override all even if worse
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@divriots/jampack",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"cache-version": {
|
|
5
5
|
"img": "v1",
|
|
6
6
|
"img-ext": "v1"
|
|
@@ -22,29 +22,29 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@divriots/cheerio": "1.0.0-rc.12",
|
|
24
24
|
"@proload/core": "^0.3.3",
|
|
25
|
-
"@swc/core": "^1.3.
|
|
25
|
+
"@swc/core": "^1.3.80",
|
|
26
26
|
"commander": "^10.0.1",
|
|
27
27
|
"deepmerge": "^4.3.1",
|
|
28
|
-
"file-type": "^18.
|
|
29
|
-
"globby": "^13.
|
|
28
|
+
"file-type": "^18.5.0",
|
|
29
|
+
"globby": "^13.2.2",
|
|
30
30
|
"hasha": "^5.2.2",
|
|
31
31
|
"html-minifier-terser": "^7.2.0",
|
|
32
32
|
"kleur": "^4.1.5",
|
|
33
|
-
"lightningcss": "^1.
|
|
33
|
+
"lightningcss": "^1.21.5",
|
|
34
34
|
"mini-svg-data-uri": "^1.4.4",
|
|
35
|
-
"ora": "^
|
|
35
|
+
"ora": "^7.0.1",
|
|
36
36
|
"sharp": "^0.32.5",
|
|
37
37
|
"svgo": "^3.0.2",
|
|
38
38
|
"table": "^6.8.1",
|
|
39
|
-
"undici": "^5.
|
|
39
|
+
"undici": "^5.23.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/html-minifier-terser": "^7.0.0",
|
|
43
|
-
"@types/node": "^
|
|
43
|
+
"@types/node": "^20.5.7",
|
|
44
44
|
"shx": "^0.3.3",
|
|
45
45
|
"ts-node": "^10.2.1",
|
|
46
|
-
"tslib": "^2.
|
|
47
|
-
"typescript": "^5.
|
|
46
|
+
"tslib": "^2.6.2",
|
|
47
|
+
"typescript": "^5.2.2"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"watch": "pnpm build --watch",
|