@divriots/jampack 0.1.6 → 0.1.7

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/compress.js CHANGED
@@ -89,7 +89,18 @@ export const compressImage = async (data, resize) => {
89
89
  const meta = await sharpFile.metadata();
90
90
  switch (meta.format) {
91
91
  case 'svg':
92
- const newData = svgo(data, {});
92
+ const newData = svgo(data, {
93
+ multipass: true,
94
+ plugins: [{
95
+ name: "preset-default",
96
+ params: {
97
+ overrides: {
98
+ removeViewBox: false,
99
+ },
100
+ },
101
+ }
102
+ ],
103
+ });
93
104
  if (newData.error || newData.modernError) {
94
105
  console.log(`Error processing svg ${data}`);
95
106
  return undefined;
@@ -100,7 +111,11 @@ export const compressImage = async (data, resize) => {
100
111
  case 'jpeg':
101
112
  case 'webp':
102
113
  //case 'gif':
103
- return await sharpFile.resize({ ...resize, fit: 'fill', withoutEnlargement: true }).toBuffer();
114
+ let sf = sharpFile;
115
+ if (resize.width && resize.height) {
116
+ sf = sf.resize({ ...resize, fit: 'fill', withoutEnlargement: true });
117
+ }
118
+ return await sf.toBuffer();
104
119
  }
105
120
  return undefined;
106
121
  };
package/dist/optimize.js CHANGED
@@ -141,7 +141,7 @@ async function processImage(file, $, imgElement) {
141
141
  originalSize: originalData.length,
142
142
  compressedSize: originalData.length
143
143
  };
144
- const newImage = await compressImage(originalData, { width: w, height: h });
144
+ const newImage = await compressImage(originalData, {});
145
145
  if (newImage && newImage.length < originalData.length) {
146
146
  if (!globalState.args.nowrite) {
147
147
  fs.writeFile(absoluteImgPath, newImage);
package/dist/options.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const default_options = {
2
2
  image: {
3
- embed_size: 0,
3
+ embed_size: 400,
4
4
  srcset_min_width: 400,
5
5
  srcset_max_width: 5120
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@divriots/jampack",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Packer for static websites",
5
5
  "author": "Georges Gomes @georges-gomes",
6
6
  "bin": {