Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ykzts/blurhash-loader

A blurhash loader module for webpack.
https://github.com/ykzts/blurhash-loader

blurhash loader webpack

Last synced: 25 days ago
JSON representation

A blurhash loader module for webpack.

Awesome Lists containing this project

README

        

# blurhash-loader

A blurhash loader module for webpack.

## Install

```console
$ npm install -D blurhash-loader
```

or

```console
$ yarn add -D blurhash-loader
```

## Usage

### webpack.config.js

```javascript
module.exports = {
module: {
rules: [
test: /\.(?:gif|jpe?g|png|webp)$/i,
use: [
{
loader: 'blurhash-loader',
options: {
componentX: 4,
componentY: 3
}
}
]
]
}
}
```

### index.tsx

```typescript
import { Blurhash } from 'react-blurhash'
import photo, { blurhash } from './photo.jpg'

export default function Home() {
return (




)
}
```

## Options

| Name | Type | Default | Description |
| ------------ | -------------------- | --------------------------- | -------------------------------------------------------- |
| `componentX` | `{Number}` | `4` | A `componentX` is the value passed directly to blurhash. |
| `componentY` | `{Number}` | `3` | A `componentY` is the value passed directly to blurhash. |
| `context` | `{String}` | `loaderContext.rootContext` | A custom file context. |
| `emitFile` | `{Boolean}` | `true` | Don't emit the file if `false` is specified. |
| `esModule` | `{Boolean}` | `true` | If enabled, use the ES modules syntax. |
| `name` | `{String\|Function}` | `'[contenthash].[ext]'` | The filename template for the target file. |
| `outputPath` | `{String\|Function}` | `undefined` | A custom output path for the target file. |
| `publicPath` | `{String\|Function}` | `undefined` | A custom public path for the target file. |

## License

[MIT](LICENSE)