lepu-test-platform-web/node_modules/url-loader
zhangbo db3ebd0df0 把之前百度云的代码移植过来 2024-01-03 15:23:47 +08:00
..
.github 把之前百度云的代码移植过来 2024-01-03 15:23:47 +08:00
node_modules 把之前百度云的代码移植过来 2024-01-03 15:23:47 +08:00
.npmignore 把之前百度云的代码移植过来 2024-01-03 15:23:47 +08:00
CHANGELOG.md 把之前百度云的代码移植过来 2024-01-03 15:23:47 +08:00
LICENSE 把之前百度云的代码移植过来 2024-01-03 15:23:47 +08:00
README.md 把之前百度云的代码移植过来 2024-01-03 15:23:47 +08:00
index.js 把之前百度云的代码移植过来 2024-01-03 15:23:47 +08:00
package.json 把之前百度云的代码移植过来 2024-01-03 15:23:47 +08:00

README.md

npm node deps tests coverage chat

URL Loader

Loads files as `base64` encoded URL

Install

npm install --save-dev url-loader

Usage

The url-loader 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: 'url-loader'
            options: {
              limit: 8192
            }  
          }
        ]
      }
    ]
  }
}

Options

Name Type Default Description
limit {Number} undefined Byte limit to inline files as Data URL
mimetype {String} extname Specify MIME type for the file (Otherwise it's inferred from the file extension)
prefix {String} false Parameters for the file-loader are valid too. They are passed to the file-loader if used

limit

If the file is greater than the limit (in bytes) the file-loader is used and all query parameters are passed to it.

The limit can be specified via loader options and defaults to no limit.

webpack.config.js

{
  loader: 'url-loader',
  options: {
    limit: 8192
  }
}

mimetype

Set the MIME type for the file. If unspecified the file extensions will be used to lookup the MIME type.

webpack.config.js

{
  loader: 'url-loader',
  options: {
    mimetype: 'image/png'
  }
}

prefix

{
  loader: 'url-loader',
  options: {
    prefix: 'img'
  }
}

Maintainers


Juho Vepsäläinen

Joshua Wiens

Artem Sapegin

Michael Ciniawsky

Alexander Krasnoyarov