美文网首页
gulp-webp生成 .jpg.webp/.png.webp格

gulp-webp生成 .jpg.webp/.png.webp格

作者: kyle背背要转运 | 来源:发表于2018-09-26 22:03 被阅读0次

    使用gulp-webp 把jpg/png生成 webP格式的图片很简单,

    原图为 1.jpg ,生成的 都是 1.webp

    在less/sass使用上不如直接 1.jpg.webp使用方便,

    只需要使用 gulp-rename调整下就好了,

    代码如下~

    const webp = require('gulp-webp');
    const rename = require('gulp-rename')
    gulp.src('./image/*.{png,jpg}')
      .pipe(rename(function (path) {
        path.extname += '.webp';
      })
      .pipe(webp())
      .pipe(gulp.dest('./'));
    

    原图为 1.jpg ,生成的 都是 1.jpg.webp

    相关文章

      网友评论

          本文标题:gulp-webp生成 .jpg.webp/.png.webp格

          本文链接:https://www.haomeiwen.com/subject/tnzjoftx.html