@divriots/jampack 0.1.0 → 0.1.1

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,3 +1,4 @@
1
+ /// <reference types="node" resolution-mode="require"/>
1
2
  import sharp from 'sharp';
2
3
  import type { Result } from './types.js';
3
4
  export declare const compressImage: (data: Buffer, resize: sharp.ResizeOptions) => Promise<Buffer | undefined>;
package/dist/optimize.js CHANGED
@@ -6,6 +6,7 @@ import { isLocal, isNumeric, translateSrc } from './utils.js';
6
6
  import sharp from "sharp";
7
7
  import options from './options.js';
8
8
  import { compressImage } from './compress.js';
9
+ import svgToMiniDataURI from 'mini-svg-data-uri';
9
10
  const compressedImages = [];
10
11
  const compressedResults = [];
11
12
  async function analyse(dir, file) {
@@ -102,7 +103,7 @@ async function processImage(dir, file, $, imgElement) {
102
103
  case 'svg':
103
104
  const compressedData = await compressImage(originalData, {});
104
105
  const svgEmbed = (compressedData && compressedData.length < originalData.length) ? compressedData : originalData;
105
- datauri = `data:image/svg+xml;utf8,${svgEmbed}`;
106
+ datauri = svgToMiniDataURI(svgEmbed.toString());
106
107
  break;
107
108
  case 'jpg':
108
109
  case 'jpeg':
@@ -117,8 +118,6 @@ async function processImage(dir, file, $, imgElement) {
117
118
  isEmbed = true;
118
119
  img.removeAttr('loading');
119
120
  img.removeAttr('decoding');
120
- img.removeAttr('width');
121
- img.removeAttr('height');
122
121
  }
123
122
  }
124
123
  if (isEmbed) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@divriots/jampack",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Packer for static websites",
5
5
  "author": "Georges Gomes @georges-gomes",
6
6
  "bin": {
@@ -29,6 +29,7 @@
29
29
  "csso": "^5.0.5",
30
30
  "globby": "^13.1.2",
31
31
  "html-minifier-terser": "^7.0.0",
32
+ "mini-svg-data-uri": "^1.4.4",
32
33
  "sharp": "^0.31.0",
33
34
  "svgo": "^2.8.0",
34
35
  "table": "^6.8.0"