DEPRECATED
image-size-loader
A webpack image loader with extra meta information for image.
Usage
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