This package has been deprecated

Author message:

This package is deprecated. See: https://neutrinojs.org/migration-guide/#neutrino-v8-to-v9

@neutrinojs/image-minify

8.3.0 • Public • Published

Neutrino Image Minify Middleware

@neutrinojs/image-minify is Neutrino middleware for optimizing images with imagemin.

NPM version NPM downloads Join the Neutrino community on Spectrum

Requirements

  • Node.js v6 LTS, v8, v9
  • Yarn v1.2.1+, or npm v5.4+
  • Neutrino v8

Installation

@neutrinojs/image-minify can be installed via the Yarn or npm clients.

Yarn

❯ yarn add @neutrinojs/image-minify

npm

❯ npm install --save @neutrinojs/image-minify

Usage

@neutrinojs/image-minify can be consumed from the Neutrino API, middleware, or presets. Require this package and plug it into Neutrino:

// Using function middleware format
const images = require('@neutrinojs/image-loader');
const imagemin = require('@neutrinojs/image-minify');

// Use with default options
neutrino.use(images);
neutrino.use(imagemin);

// Usage showing default options
neutrino.use(imagemin, {
  imagemin: {
    plugins: [
      gifsicle(),
      svgo(),
      pngquant(),
      mozjpeg(),
      webp()
    ]
  },
  plugin: {
    name: '[path][name].[ext]',
    test: /\.(png|jpg|jpeg|gif|webp)$/
  },
  useId: 'imagemin',
  rules: ['svg', 'img'],
  pluginId: 'imagemin',
});
// Using object or array middleware format

// Use with default options
module.exports = {
  use: ['@neutrinojs/image-minify']
};

// Usage showing default options
module.exports = {
  use: [
    ['@neutrinojs/image-minify', {
      imagemin: {},
      plugin: {
        name: '[path][name].[ext]',
        test: /\.(png|jpg|jpeg|gif|webp)$/
      },
      rules: ['svg', 'img'],
      pluginId: 'imagemin'
    }]
  ]
};
  • imagemin: Set options for imagemin.
  • plugin: Set options for imagemin-webpack's ImageminWebpackPlugin.
  • rules: Specify rules for the application of imagemin.
  • pluginId: The imagemin plugin identifier. Override this to add an additional imagemin plugin instance.

Customization

@neutrinojs/image-minify creates some conventions to make overriding the configuration easier once you are ready to make changes.

Rules

The following is a list of rules and their identifiers which can be overridden:

Name Description Environments and Commands
img Optimize JPEG, PNG, GIF, and WEBP files imported from modules. Contains a single loader named imagemin. all
svg Optimize SVG files imported from modules. Contains a single loader named imagemin. all

Plugins

The following is a list of plugins and their identifiers which can be overridden:

Name Description Environments and Commands
imagemin Optimize any images added by other webpack plugins (e.g. copy-webpack-plugin). all

Contributing

This middleware is part of the neutrino-dev repository, a monorepo containing all resources for developing Neutrino and its core presets and middleware. Follow the contributing guide for details.

Package Sidebar

Install

npm i @neutrinojs/image-minify

Weekly Downloads

84

Version

8.3.0

License

MPL-2.0

Unpacked Size

5.82 kB

Total Files

4

Last publish

Collaborators

  • edmorley
  • eliperelman
  • helfi92
  • timkelty