rollup-generate-image-sizes
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -16,2 +16,5 @@ 'use strict'; | ||
// A helper function for transform single items to array | ||
const arrayify = (a) => (Array.isArray(a) ? a : [a]); | ||
var index = (options = {}) => { | ||
@@ -42,5 +45,8 @@ // Load options | ||
// Glob for the directories | ||
const dirGlob = arrayify(dir).length > 1 ? `{${arrayify(dir).join(',')}}` : arrayify(dir)[0]; | ||
return globby__default['default']( | ||
// Finds all the images we want based on dir and inputFormat | ||
`{${Array.isArray(dir) ? dir.join(',') : dir}}/**/!(*@*|*#*).{${inputFormat.join(',')}}`, | ||
`${dirGlob}/**/!(*@*|*#*).{${inputFormat.join(',')}}`, | ||
) | ||
@@ -59,3 +65,3 @@ .then((images) => Promise.allSettled( | ||
.then((metadata) => Promise.allSettled( | ||
(Array.isArray(size) ? size : [size]).map((scaleWidth) => { | ||
(arrayify(size)).map((scaleWidth) => { | ||
// If the width we want to scale to is larger than the original | ||
@@ -67,4 +73,5 @@ // width and forceUpscale is not set, we skip this. | ||
return Promise.all( | ||
(Array.isArray(outputFormat) ? outputFormat : [outputFormat]) | ||
(arrayify(outputFormat)) | ||
.map((format) => sharpObj | ||
.clone() | ||
.resize(scaleWidth) | ||
@@ -71,0 +78,0 @@ .toFormat(format, { quality }) |
@@ -9,2 +9,5 @@ import globby from 'globby'; | ||
// A helper function for transform single items to array | ||
const arrayify = (a) => (Array.isArray(a) ? a : [a]); | ||
var index = (options = {}) => { | ||
@@ -35,5 +38,8 @@ // Load options | ||
// Glob for the directories | ||
const dirGlob = arrayify(dir).length > 1 ? `{${arrayify(dir).join(',')}}` : arrayify(dir)[0]; | ||
return globby( | ||
// Finds all the images we want based on dir and inputFormat | ||
`{${Array.isArray(dir) ? dir.join(',') : dir}}/**/!(*@*|*#*).{${inputFormat.join(',')}}`, | ||
`${dirGlob}/**/!(*@*|*#*).{${inputFormat.join(',')}}`, | ||
) | ||
@@ -52,3 +58,3 @@ .then((images) => Promise.allSettled( | ||
.then((metadata) => Promise.allSettled( | ||
(Array.isArray(size) ? size : [size]).map((scaleWidth) => { | ||
(arrayify(size)).map((scaleWidth) => { | ||
// If the width we want to scale to is larger than the original | ||
@@ -60,4 +66,5 @@ // width and forceUpscale is not set, we skip this. | ||
return Promise.all( | ||
(Array.isArray(outputFormat) ? outputFormat : [outputFormat]) | ||
(arrayify(outputFormat)) | ||
.map((format) => sharpObj | ||
.clone() | ||
.resize(scaleWidth) | ||
@@ -64,0 +71,0 @@ .toFormat(format, { quality }) |
{ | ||
"name": "rollup-generate-image-sizes", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Automatically generate image sizes for use in srcsets.", | ||
@@ -5,0 +5,0 @@ "main": "dist/rollup-generate-image-sizes.cjs.js", |
@@ -32,3 +32,3 @@ # rollup-generate-image-sizes | ||
Note: All output files are named in the pattern `<original-filename>@<size>w.<file-extension>`. The plugin looks for the `@` symbol to determine which files have already been converted, which means that all files with the `@` will be ignored. | ||
Note: All output files are named in the pattern `<original-filename>@<size>w.<file-extension>`. The plugin looks for the `@` symbol to determine which files have already been converted, which means that all files with the `@` will be ignored. Files with `#` are also ignored. | ||
@@ -35,0 +35,0 @@ ### Configuration |
@@ -9,2 +9,5 @@ import globby from 'globby'; | ||
// A helper function for transform single items to array | ||
const arrayify = (a) => (Array.isArray(a) ? a : [a]); | ||
export default (options = {}) => { | ||
@@ -35,5 +38,8 @@ // Load options | ||
// Glob for the directories | ||
const dirGlob = arrayify(dir).length > 1 ? `{${arrayify(dir).join(',')}}` : arrayify(dir)[0]; | ||
return globby( | ||
// Finds all the images we want based on dir and inputFormat | ||
`{${Array.isArray(dir) ? dir.join(',') : dir}}/**/!(*@*|*#*).{${inputFormat.join(',')}}`, | ||
`${dirGlob}/**/!(*@*|*#*).{${inputFormat.join(',')}}`, | ||
) | ||
@@ -52,3 +58,3 @@ .then((images) => Promise.allSettled( | ||
.then((metadata) => Promise.allSettled( | ||
(Array.isArray(size) ? size : [size]).map((scaleWidth) => { | ||
(arrayify(size)).map((scaleWidth) => { | ||
// If the width we want to scale to is larger than the original | ||
@@ -60,4 +66,5 @@ // width and forceUpscale is not set, we skip this. | ||
return Promise.all( | ||
(Array.isArray(outputFormat) ? outputFormat : [outputFormat]) | ||
(arrayify(outputFormat)) | ||
.map((format) => sharpObj | ||
.clone() | ||
.resize(scaleWidth) | ||
@@ -64,0 +71,0 @@ .toFormat(format, { quality }) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
13127
207
0