@eoleo/image-size-loader

1.0.1 • Public • Published

DEPRECATED

Look at the new repository

image-size-loader

A webpack image loader with extra meta information for image.

Usage

Documentation: Using loaders

Getting Started

To begin, you'll need to install image-size-loader:

$ npm install image-size-loader --save-dev

Then add the loader to your webpack config. For example:

// webpack.config.js
module.exports = {
  module: {
    rules: [
      {
        test: /\.(gif|jpe?g|png|svg)$/,
        use: [
          {
            loader: 'image-size-loader',
            options: {}
          }
        ]
      }
    ]
  }
};

Import images

Import (or require) the target file(s) in one of the bundle's files:

// bundle file
import image from './file.png';

That return an object with extra meta info:

  // console.log(image);
  {
    width: 150,
    height: 50,
    type: "png",
    src: "/assets/images/file.png",
    bytes: 1234
  }

More options

More webpack config exemple on file-loader documentation

Documentation: file-loaders

Readme

Keywords

Package Sidebar

Install

npm i @eoleo/image-size-loader

Weekly Downloads

400

Version

1.0.1

License

Apache-2.0

Unpacked Size

18 kB

Total Files

6

Last publish

Collaborators

  • eoleo