2.1.3 • Published 6 years ago

image-web-loader v2.1.3

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

image-web-loader

NPM version

一、简介

用于react-native for web的webpack 图片加载器

支持web端根据devicePixelRatio 来加载@1x @1.5x @2x @3x @4x

例如: require('image/a.jpg'); --> images/a@1x.jpg .....

或者 require('image!x')

二、安装

npm install image-web-loader --save-dev

 

三、使用

Webpack config example:

const RequireImageXAssetPlugin  =require('image-web-loader').RequireImageXAssetPlugin;

module.exports = {
  plugins:[
    ....
    new RequireImageXAssetPlugin(path.resolve('assets/images'))
  ]
  module: {
    loaders: [
      {
        test: /\.(gif|jpeg|jpg|png|svg)$/,
        loader: 'image-web-loader!file-loader',
        query: {
          //true: require('a.jpg') 返回url 否则返回{width:xx,height:xx,uri:xxx}
          onlyWeb:false,
          progressive: true,
          optimizationLevel: 7,
          interlaced: false,
          pngquant: {
            quality: '65-90',
            speed: 4
          }
        }
      }
    ]
  }
}

Code example:

  // ---> {uri:'xxx/hello(@1x|@1.5x|@2x|@3x|@4x).png',width:xx,height:xx}
  require('./image/icon.png')  

  // --->  {uri:'xxx/assets/images/hello.(png|gif|jpg|ico|bmp)',width:xx,height:xx}
  require('image!hello')  

四、开源许可

基于 MIT License 开源,使用代码只需说明来源,或者引用 license.txt 即可。

2.1.3

6 years ago

2.1.2

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

1.1.19

6 years ago

1.1.18

7 years ago

1.1.17

7 years ago

1.1.16

7 years ago

1.1.15

7 years ago

1.1.14

7 years ago

1.1.13

7 years ago

1.1.12

7 years ago

1.1.11

7 years ago

1.1.10

7 years ago

1.1.9

7 years ago

1.1.8

7 years ago

1.1.7

7 years ago

1.1.6

7 years ago

1.1.5

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago