[![npm][npm]][npm-url] [![node][node]][node-url] [![deps][deps]][deps-url] [![tests][tests]][tests-url] [![coverage][cover]][cover-url] [![chat][chat]][chat-url]

URL Loader

Loads files as `base64` encoded URL

Install

```bash npm install --save-dev url-loader ```

Usage

The `url-loader` 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: '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`](https://github.com/webpack-contrib/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`](https://github.com/webpack-contrib/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** ```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** ```js { loader: 'url-loader', options: { mimetype: 'image/png' } } ``` ### `prefix` ```js { loader: 'url-loader', options: { prefix: 'img' } } ```

Maintainers


Juho Vepsäläinen

Joshua Wiens

Artem Sapegin

Michael Ciniawsky

Alexander Krasnoyarov
[npm]: https://img.shields.io/npm/v/url-loader.svg [npm-url]: https://npmjs.com/package/url-loader [node]: https://img.shields.io/node/v/url-loader.svg [node-url]: https://nodejs.org [deps]: https://david-dm.org/webpack-contrib/url-loader.svg [deps-url]: https://david-dm.org/webpack-contrib/url-loader [tests]: http://img.shields.io/travis/webpack-contrib/url-loader.svg [tests-url]: https://travis-ci.org/webpack-contrib/url-loader [cover]: https://coveralls.io/repos/github/webpack-contrib/url-loader/badge.svg [cover-url]: https://coveralls.io/github/webpack-contrib/url-loader [chat]: https://badges.gitter.im/webpack/webpack.svg [chat-url]: https://gitter.im/webpack/webpack