https://github.com/hxfdarling/mp-img-loader
https://github.com/hxfdarling/mp-img-loader
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/hxfdarling/mp-img-loader
- Owner: hxfdarling
- License: mit
- Created: 2018-04-30T16:50:25.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-05-01T16:13:06.000Z (about 7 years ago)
- Last Synced: 2025-02-19T13:46:44.717Z (4 months ago)
- Language: JavaScript
- Size: 121 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
Install
```bash
npm install --save-dev mp-imageloader
```Usage
The `mp-imageloader` works like the [`file-loader`](https://github.com/webpack-contrib/file-loader), but can return a DataURL if the file is smaller than a byte limit.
```js
import img from './image.png';
```**webpack.config.js**
```js
module.exports = {
module: {
rules: [
{
test: /\.(png|jpg|gif)$/,
use: [
{
loader: 'mp-imageloader',
options: {},
},
],
},
],
},
};
```Options
| Name | Type | Default | Description |
| :-------------------------: | :--------: | :-----------: | :------------------------------------------------------------------------------- |
| **[`mimetype`](#mimetype)** | `{String}` | `extname` | Specify MIME type for the file (Otherwise it's inferred from the file extension) |
| **[`fallback`](#fallback)** | `{String}` | `file-loader` | Specify `loader` for the file when file is greater than the limit (in bytes) |### `mimetype`
Set the MIME type for the file. If unspecified the file extensions will be used to lookup the MIME type.
**webpack.config.js**
```js
{
loader: 'mp-imageloader',
options: {
mimetype: 'image/png'
}
}
```### `fallback`
**webpack.config.js**
```js
{
loader: 'mp-imageloader',
options: {
fallback: 'responsive-loader'
}
}
```