Skip to content
This repository was archived by the owner on Mar 17, 2021. It is now read-only.

Commit 636ebed

Browse files
evilebottnawimichael-ciniawsky
authored andcommittedSep 14, 2017
feat: add fallback option (#88)
1 parent f3f5fce commit 636ebed

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed
 

‎README.md

+15-1
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,12 @@ module.exports = {
5656
|:--:|:--:|:-----:|:----------|
5757
|**`limit`**|`{Number}`|`undefined`|Byte limit to inline files as Data URL|
5858
|**`mimetype`**|`{String}`|`extname`|Specify MIME type for the file (Otherwise it's inferred from the file extension)|
59+
|**`fallback`**|`{String}`|`file-loader`|Specify `loader` for the file when file is greater than the limit (in bytes)|
5960

6061
### `limit`
6162

62-
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.
63+
If the file is greater than the limit (in bytes) the [`file-loader`](https://github.com/webpack-contrib/file-loader) is used by default and all query parameters are passed to it.
64+
You can use other loader using `fallback` option.
6365

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

@@ -87,6 +89,18 @@ Set the MIME type for the file. If unspecified the file extensions will be used
8789
}
8890
```
8991

92+
### `fallback`
93+
94+
**webpack.config.js**
95+
```js
96+
{
97+
loader: 'url-loader',
98+
options: {
99+
fallback: 'responsive-loader'
100+
}
101+
}
102+
```
103+
90104
<h2 align="center">Maintainers</h2>
91105

92106
<table>

‎index.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ module.exports = function(content) {
3131
return "module.exports = " + JSON.stringify("data:" + (mimetype ? mimetype + ";" : "") + "base64," + content.toString("base64"));
3232
}
3333

34-
var fileLoader = require("file-loader");
34+
var fallback = options.fallback || "file-loader";
35+
var fallbackLoader = require(fallback);
3536

36-
return fileLoader.call(this, content);
37+
return fallbackLoader.call(this, content);
3738
}
3839

3940
module.exports.raw = true;

0 commit comments

Comments
 (0)
This repository has been archived.