@divriots/jampack 0.5.2 → 0.6.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/LICENSE +0 -0
- package/README.md +0 -0
- package/dist/compress.d.ts +0 -1
- package/dist/compress.js +29 -3
- package/dist/index.js +0 -0
- package/package.json +10 -9
package/LICENSE
CHANGED
|
File without changes
|
package/README.md
CHANGED
|
File without changes
|
package/dist/compress.d.ts
CHANGED
package/dist/compress.js
CHANGED
|
@@ -3,6 +3,7 @@ import * as path from 'path';
|
|
|
3
3
|
import { optimize as svgo } from 'svgo';
|
|
4
4
|
import { minify as htmlminifier } from 'html-minifier-terser';
|
|
5
5
|
import { minify as csso } from 'csso';
|
|
6
|
+
import { transform as lightcss } from 'lightningcss';
|
|
6
7
|
import { formatBytes } from './utils.js';
|
|
7
8
|
import sharp from 'sharp';
|
|
8
9
|
import swc from '@swc/core';
|
|
@@ -50,9 +51,34 @@ const processFile = async (file, stats) => {
|
|
|
50
51
|
break;
|
|
51
52
|
case '.css':
|
|
52
53
|
const cssdata = await fs.readFile(file);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
// Compress with csso
|
|
55
|
+
const cssoCSSData = Buffer.from(await csso(cssdata.toString(), { comments: false }).css);
|
|
56
|
+
// Compress with lightningcss
|
|
57
|
+
let lightCSSData;
|
|
58
|
+
try {
|
|
59
|
+
lightCSSData = lightcss({
|
|
60
|
+
filename: 'style.css',
|
|
61
|
+
code: cssdata,
|
|
62
|
+
minify: true,
|
|
63
|
+
sourceMap: false,
|
|
64
|
+
}).code;
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
// Error while processing with lightningcss
|
|
68
|
+
// Ignore
|
|
69
|
+
}
|
|
70
|
+
// Pick the best
|
|
71
|
+
if (cssoCSSData && lightCSSData) {
|
|
72
|
+
writeData =
|
|
73
|
+
cssoCSSData.length <= lightCSSData.length
|
|
74
|
+
? cssoCSSData
|
|
75
|
+
: lightCSSData;
|
|
76
|
+
}
|
|
77
|
+
else if (cssoCSSData && !lightCSSData) {
|
|
78
|
+
writeData = cssoCSSData;
|
|
79
|
+
}
|
|
80
|
+
else if (!cssoCSSData && lightCSSData) {
|
|
81
|
+
writeData = lightCSSData;
|
|
56
82
|
}
|
|
57
83
|
break;
|
|
58
84
|
case '.js':
|
package/dist/index.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@divriots/jampack",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Packer for static websites",
|
|
5
5
|
"author": "Georges Gomes @georges-gomes",
|
|
6
6
|
"bin": {
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"hasha": "^5.2.2",
|
|
35
35
|
"html-minifier-terser": "^7.1.0",
|
|
36
36
|
"kleur": "^4.1.5",
|
|
37
|
+
"lightningcss": "^1.18.0",
|
|
37
38
|
"mini-svg-data-uri": "^1.4.4",
|
|
38
39
|
"ora": "^6.1.2",
|
|
39
40
|
"sharp": "^0.31.2",
|
|
@@ -47,16 +48,16 @@
|
|
|
47
48
|
"tslib": "^2.4.1",
|
|
48
49
|
"typescript": "^4.9.3"
|
|
49
50
|
},
|
|
50
|
-
"engines": {
|
|
51
|
-
"node": ">=14.0.0"
|
|
52
|
-
},
|
|
53
|
-
"bugs": "https://github.com/divriots/jampack/issues",
|
|
54
|
-
"keywords": [],
|
|
55
|
-
"types": "dist/index.d.ts",
|
|
56
51
|
"scripts": {
|
|
57
52
|
"watch": "pnpm build --watch",
|
|
58
53
|
"try": "shx rm -fr demo && cp -R demo_avif demo && node ./dist/index.js ./demo --nocache",
|
|
59
54
|
"build": "shx rm -rf dist && tsc -b",
|
|
60
55
|
"lint": "eslint . --ext .ts --config .eslintrc"
|
|
61
|
-
}
|
|
62
|
-
|
|
56
|
+
},
|
|
57
|
+
"engines": {
|
|
58
|
+
"node": ">=14.0.0"
|
|
59
|
+
},
|
|
60
|
+
"bugs": "https://github.com/divriots/jampack/issues",
|
|
61
|
+
"keywords": [],
|
|
62
|
+
"types": "dist/index.d.ts"
|
|
63
|
+
}
|