npm install --save-dev mp-imageloader
The mp-imageloader
works like the file-loader
, but can return a DataURL if the file is smaller than a byte limit.
import img from './image.png';
webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.(png|jpg|gif)$/,
use: [
{
loader: 'mp-imageloader',
options: {},
},
],
},
],
},
};
Name | Type | Default | Description |
---|---|---|---|
mimetype |
{String} |
extname |
Specify MIME type for the file (Otherwise it's inferred from the file extension) |
fallback |
{String} |
file-loader |
Specify loader for the file when file is greater than the limit (in bytes) |
Set the MIME type for the file. If unspecified the file extensions will be used to lookup the MIME type.
webpack.config.js
{
loader: 'mp-imageloader',
options: {
mimetype: 'image/png'
}
}
webpack.config.js
{
loader: 'mp-imageloader',
options: {
fallback: 'responsive-loader'
}
}