New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@mara/image-loader

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mara/image-loader

A loader for webpack which compress png/svg/jpg images

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-57.14%
Maintainers
2
Weekly downloads
 
Created
Source

@mara/image-loader

A loader for webpack which compress png/svg/jpg images.

  • Use tinify to compress png/jpg
    • Cache tinify results
    • Dynamic scheduling tinify keys
  • Use svgo to compress svg

Install

yarn add @mara/image-loader -D

Usage

webpack.config.js

With url-loader:

module.exports = {
  module: {
    rules: [
      {
        test: /\.(bmp|png|jpe?g|gif|webp|svg)$/,
        loader: require.resolve('url-loader'),
        options: {
          limit: 1024 * 4,
          tinifyKeys: [tinify_key1, [...tinify_keyn]],
          minify: process.env.NODE_ENV === 'production',
          // use image-loader when a target file's size exceeds the limit
          fallback: require.resolve('@mara/image-loader'),
          name: `static/img/[name].[contenthash:8].[ext]`
        }
      }
    ]
  }
}

Use alone:

module.exports = {
  module: {
    rules: [
      {
        test: /\.(bmp|png|jpe?g|gif|webp|svg)$/,
        loader: require.resolve('@mara/image-loader'),
        options: {
          tinifyKeys: [tinify_key1, [...tinify_keyn]],
          minify: process.env.NODE_ENV === 'production',
          name: `static/img/[name].[contenthash:8].[ext]`
        }
      }
    ]
  }
}

Options

NameTypeDefaultDescription
namestring'[hash].[ext]'Custom filename template. See placeholders for details
tinifyKeysstring[][]Developer API keys from tinypng.com
minifybooleantrueSet false to disable compression, equivalent to file-loader

Keywords

FAQs

Package last updated on 30 Oct 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc