diff --git a/packages/images/README.md b/packages/images/README.md index bea56e7..a66abd6 100644 --- a/packages/images/README.md +++ b/packages/images/README.md @@ -117,6 +117,7 @@ plugins: { folders: [ { src: '/images/*', // glob of where your original images are. Relative to rootDir/process.cwd() defined in your elder.config.js. Careful with **. + // src: 'articles/**/*' is also acceptable output: '/images/', // where files should be put within the distDir defined in your elder.config.js. }, ], diff --git a/packages/images/index.js b/packages/images/index.js index 0fefcc7..9e41915 100644 --- a/packages/images/index.js +++ b/packages/images/index.js @@ -34,6 +34,7 @@ const processImages = async ({ images = [], widths = defaultWidths, scales = defaultScales, + plugin = {}, s3, debug, }) => { @@ -286,15 +287,15 @@ const plugin = { plugin.crossPlatformRoot = plugin.settings.rootDir.replace(/\\/gim, '/'); const imagesToProcess = folders.reduce((out, folder) => { - const relGlob = folder.src.replace('.', '').replace(/\*/g, ''); - fs.ensureDirSync(path.join(plugin.settings.distDir, folder.output)); - const files = glob.sync(path.join(plugin.settings.rootDir, folder.src)); + const files = glob.sync(path.join(plugin.settings.rootDir, folder.src + `.{${imageFileTypes.join(',')}}`)); if (Array.isArray(files)) { files - .filter((file) => imageFileTypes.includes(file.split('.').pop().toLowerCase())) .filter((file) => !file.split('/').pop().includes('-ejs')) .forEach((file) => { + // fix manifest not found and wrong output folder when using **/* + const relGlob = file.replace(plugin.settings.rootDir, '').replace(file.split('/').pop(), ''); + const crossPlatformFile = file.replace(plugin.crossPlatformRoot, ''); const name = crossPlatformFile.replace(relGlob, ''); @@ -364,6 +365,7 @@ const plugin = { images: plugin.imagesToProcess, widths, scales, + plugin, s3: plugin.config.s3, debug: plugin.config.debug, });