Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Help] no output from plugin? #5

Open
SamuelMiller opened this issue May 15, 2022 · 6 comments
Open

[Help] no output from plugin? #5

SamuelMiller opened this issue May 15, 2022 · 6 comments

Comments

@SamuelMiller
Copy link

SamuelMiller commented May 15, 2022

I've installed sharp and this plugin: npm install sharp gulp-sharp-responsive --save-dev
essentially following the instructions on the npm website (https://www.npmjs.com/package/gulp-sharp-responsive) as well as this tutorial: https://dev.to/khalyomede/create-responsive-images-with-gulp-sharp-responsive-9c6

When I run "npm run img" or "gulp sharpImages" (see below), all I get is this in the terminal with no result:

[14:12:35] Starting 'sharpImages'...
[14:12:35] Finished 'sharpImages' after 227 ms

I tried this:

const { src, dest } = require("gulp");
const sharpResponsive = require("gulp-sharp-responsive");

const img = () => src('src/assets/images/process/**/*.jpg')
    .pipe(sharpResponsive({
        formats: [
            // jpeg
            { width: 640, format: "jpeg", rename: { suffix: "-sm" } },
            { width: 768, format: "jpeg", rename: { suffix: "-md" } },
            { width: 1024, format: "jpeg", rename: { suffix: "-lg" } },
            // webp
            { width: 640, format: "webp", rename: { suffix: "-sm" } },
            { width: 768, format: "webp", rename: { suffix: "-md" } },
            { width: 1024, format: "webp", rename: { suffix: "-lg" } },
            // avif
            { width: 640, format: "avif", rename: { suffix: "-sm" } },
            { width: 768, format: "avif", rename: { suffix: "-md" } },
            { width: 1024, format: "avif", rename: { suffix: "-lg" } },
        ]
    }))
    .pipe(dest('test'))

module.exports = {
    img,
};

with this in my package.json:

 "scripts": {
     "img": "gulp img"
  },

Alternatively, I tried the classic function approach. Same result:

function sharpImages() {
    return src('src/assets/images/process/**/*.jpg')
        .pipe(sharpResponsive({
            formats: [
                // jpeg
                { width: 640, format: "jpeg", rename: { suffix: "-sm" } },
                { width: 768, format: "jpeg", rename: { suffix: "-md" } },
                { width: 1024, format: "jpeg", rename: { suffix: "-lg" } },
                // webp
                { width: 640, format: "webp", rename: { suffix: "-sm" } },
                { width: 768, format: "webp", rename: { suffix: "-md" } },
                { width: 1024, format: "webp", rename: { suffix: "-lg" } },
                // avif
                { width: 640, format: "avif", rename: { suffix: "-sm" } },
                { width: 768, format: "avif", rename: { suffix: "-md" } },
                { width: 1024, format: "avif", rename: { suffix: "-lg" } },
            ]
        }))
        .pipe(dest('test'))
}

exports.sharpImages = sharpImages;

No test directory, no images, nothing. I am using node v16.15.0. Any suggestions?

@khalyomede
Copy link
Owner

Hi @SamuelMiller, thanks for taking your time reporting this issue!

I just answered here, but basically if you can give me a repository I can clone locally (with the images) so I can give it a try on my local machine it would help me figure out what's going wrong

@SamuelMiller
Copy link
Author

I'll do this sometime this week or the next. Thanks for replying so soon.

@SamuelMiller
Copy link
Author

SamuelMiller commented May 22, 2022 via email

@khalyomede
Copy link
Owner

khalyomede commented May 22, 2022

Great to read again!

I just replied on dev.to with a guess (maybe the sharp compilation during the installation was corrupted).

Glad it finally works for you!

Feel free to close the issue if you do not find any blockers anymore 🙏

@SamuelMiller
Copy link
Author

SamuelMiller commented Oct 11, 2022 via email

@khalyomede
Copy link
Owner

Hi, thanks a lot for the suggestion! Sorry this project went under radar since I'm on another bigger project of my own...

I'll add your suggestion to make the usage clearer. For the issue I will see if I can fix it asap, I know the issue is awake since a lot. If you want to try to fiddle with the code for a solution I'm open for PR as well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants