1.0.2 • Published 4 years ago

@wok-cli/plugin-imagemin v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

Imagemin Plugin

Image optimization plugin for Wok. Implements gulp-imagemin.

Hook typesProduction onlyPurpose
lazypipepartly1optimization
  1. svg files are always optimized.

Installation

npm i @wok-cli/plugin-imagemin --save-dev

Usage

When applied to a stream of files this plugin will apply gulp-imagemin to matching image files. SVG Files will be always optimized while every other file format will be optimized just on production builds.

One possible injection point is the process hook of the copy task in @wok-cli/tasks.

const $ = require('@wok-cli/core');
const { copy } = require('@wok-cli/tasks');
const imagemin = require('@wok-cli/plugin-imagemin');

const copyTask = $.task(copy, {
  src: 'static/**/*.*',
  dest: 'public/'
});

copyTask.tap('process', 'imagemin', imagemin);

export.copy = copyTask

Parameters

Configuration path: imagemin.

parametertypedefaultnote
patternstring'**/*.{png,jpg,gif,svg,webp}'Glob pattern matching image files
// ...

const copyTask = $.task(copy, {
  src: 'static/**/*.*',
  dest: 'public/',
  'hooks:process': {
    // process just jpg and svg files
    imagemin: '**/*.{jpg,svg}',
  },
});

copyTask.tap('process', 'imagemin', imagemin);

// ...