jaredLunde / snowpack-plugin-imagemin

Use @imagemin to optimize your images in Snowpack
MIT License
2 stars 0 forks source link
imagemin snowpack snowpack-imagemin snowpack-plugin snowpack-plugin-imagemin

snowpack-plugin-imagemin

Use imagemin to optimize your images in Snowpack. This plugin will only compress images in production after your build finishes.

npm i snowpack-plugin-imagemin

Build status NPM Version MIT License


Quick start

// snowpack.config.js
module.exports = {
  plugins: [
    [
      'snowpack-plugin-imagemin',
      {
        /* see "Plugin Options" below */
        include: ['**/*.jpg', '**/*.png'],
        plugins: [
          require('imagemin-mozjpeg')({quality: 90, progressive: true}),
          require('imagemin-optipng')({optimizationLevel: 7}),
        ],
      },
    ],
  ],
}

Plugin Options

export interface SnowpackPluginImageminOptions {
  /**
   * Includes only the specified globs. Globs should be relative
   * to the build directory, which is `build/` by default in Snowpack.
   * *
   * ! This option is required !
   */
  include: Parameters<typeof imagemin>[0]
  /**
   * Plugins to use.
   * @see https://www.npmjs.com/search?q=keywords:imageminplugin
   *
   * ! This option is required !
   */
  plugins: imagemin.Options['plugins']
}

LICENSE

MIT