@divriots/jampack 0.11.3 → 0.11.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.
@@ -1,14 +1,7 @@
1
- import { minify as csso } from 'csso';
2
1
  import { transform as lightcss, transformStyleAttribute as lightcssStyleAttribute, } from 'lightningcss';
3
2
  export async function compressCSS(originalCode, type) {
4
- // csso only support css files. No inline style
5
- let cssoCSSData = undefined;
6
- if (type !== 'inline') {
7
- // Compress with csso
8
- cssoCSSData = Buffer.from(await csso(originalCode.toString(), { comments: false }).css);
9
- }
10
3
  // Compress with lightningcss
11
- let lightCSSData;
4
+ let lightCSSData = undefined;
12
5
  try {
13
6
  const options = {
14
7
  code: originalCode,
@@ -24,18 +17,10 @@ export async function compressCSS(originalCode, type) {
24
17
  }
25
18
  catch (e) {
26
19
  // Error while processing with lightningcss
27
- // Ignore, we have csso as backup
20
+ // Take original code
28
21
  }
29
22
  let resultBuffer = undefined;
30
- // Pick the best
31
- if (cssoCSSData && lightCSSData) {
32
- resultBuffer =
33
- cssoCSSData.length <= lightCSSData.length ? cssoCSSData : lightCSSData;
34
- }
35
- else if (cssoCSSData && !lightCSSData) {
36
- resultBuffer = cssoCSSData;
37
- }
38
- else if (!cssoCSSData && lightCSSData) {
23
+ if (lightCSSData && lightCSSData.length < originalCode.length) {
39
24
  resultBuffer = lightCSSData;
40
25
  }
41
26
  return resultBuffer || originalCode;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@divriots/jampack",
3
- "version": "0.11.3",
3
+ "version": "0.11.4",
4
4
  "description": "Packer for static websites",
5
5
  "author": "Georges Gomes @georges-gomes",
6
6
  "bin": {
@@ -19,12 +19,10 @@
19
19
  "@divriots/cheerio": "1.0.0-rc.12",
20
20
  "@proload/core": "^0.3.3",
21
21
  "@swc/core": "^1.3.57",
22
- "@types/csso": "^5.0.0",
23
22
  "@types/html-minifier-terser": "^7.0.0",
24
23
  "@types/sharp": "^0.32.0",
25
24
  "@types/svgo": "^3.0.0",
26
25
  "commander": "^10.0.1",
27
- "csso": "^5.0.5",
28
26
  "deepmerge": "^4.3.1",
29
27
  "file-type": "^18.4.0",
30
28
  "globby": "^13.1.4",