# @areslabs/image-suffix-webpack-plugin

> image require plugin to resolve @1x @2x @3x

Latest version **1.0.0** (published 2019-09-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install @areslabs/image-suffix-webpack-plugin
pnpm add @areslabs/image-suffix-webpack-plugin
yarn add @areslabs/image-suffix-webpack-plugin
bun add @areslabs/image-suffix-webpack-plugin
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2019-09-24 |
| First published | 2019-09-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 2.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | areslabs |
| Maintainers | yvettelau, zangguodong, ykforerlang, jameshen |
| Keywords | webpack, plugin |

## Links

- npm: https://www.npmjs.com/package/@areslabs/image-suffix-webpack-plugin
- npm.io page: https://npm.io/package/@areslabs/image-suffix-webpack-plugin

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2019-09-24

## README

# ImageSuffixPlugin

这个webpack插件是用来解决react native转web项目中对图片的require问题的。
在react-native中，我们可以这样加载图片
```javascript
render() {
  return (
    <Image source={{require('../assets/logo.png')}} />
  )
}
```
图片是目录是这样的
```
logo@1x.png
logo@2x.png
logo@3x.png
```

在`react-native`转web的过程中，会因此而报错(模块找不到)。
`ImageSuffixPlugin`可以在查找图片模块时自动侦测@1x, @2x, @3x的图片，webpack配置如下:
```javascript
plugins: {
  new ImageSuffixPlugin(),
  ...
}
```


## 构造器参数

ImageSuffixPlugin构造器有两个参数`ImageSuffixPlugin(pattern, suffixs)`

`pattern`: `RegExp`
符合pattern格式的图片才会用到自动侦测，默认值是`/\.(jpe?g|png|gif)$/gi`

`suffixs`: `array`
后缀格式，从前往后侦测，默认值是`['@2x', '@3x', '@1x']`

---
_Source: https://npm.io/package/@areslabs/image-suffix-webpack-plugin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
