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

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: webpack-contrib/url-loader
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 5574ed3ec10c71440f6de32f0abcd5d2609ffb79
Choose a base ref
...
head repository: webpack-contrib/url-loader
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 11dce14d6025a58b83d40167a74ddd989c702a72
Choose a head ref
  • 8 commits
  • 5 files changed
  • 4 contributors

Commits on Jun 13, 2017

  1. Copy the full SHA
    ced5990 View commit details

Commits on Jun 20, 2017

  1. Copy the full SHA
    2de70bb View commit details

Commits on Sep 13, 2017

  1. Copy the full SHA
    f3f5fce View commit details

Commits on Sep 14, 2017

  1. Copy the full SHA
    636ebed View commit details

Commits on Oct 2, 2017

  1. Copy the full SHA
    d19ee2d View commit details

Commits on Oct 3, 2017

  1. chore: Fix mime version

    joshwiens committed Oct 3, 2017
    Copy the full SHA
    a1e1fef View commit details
  2. chore(release): 0.6.0

    joshwiens committed Oct 3, 2017
    Copy the full SHA
    1934507 View commit details
  3. Copy the full SHA
    11dce14 View commit details
Showing with 73 additions and 26 deletions.
  1. +16 −0 CHANGELOG.md
  2. +8 −6 README.md
  3. +22 −16 index.js
  4. +18 −0 options.json
  5. +9 −4 package.json
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,22 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

<a name="0.6.0"></a>
# [0.6.0](https://github.com/webpack-contrib/url-loader/compare/v0.5.9...v0.6.0) (2017-10-03)


### Features

* **index:** add options validation (`schema-utils`) ([#78](https://github.com/webpack-contrib/url-loader/issues/78)) ([ced5990](https://github.com/webpack-contrib/url-loader/commit/ced5990))
* add `fallback` option ([#88](https://github.com/webpack-contrib/url-loader/issues/88)) ([636ebed](https://github.com/webpack-contrib/url-loader/commit/636ebed))

### Security

* Updates Mime pacakge due to Regex DOS security vulnerability ([#87](https://github.com/webpack-contrib/url-loader/issues/87)) ([d19ee2d](https://github.com/webpack-contrib/url-loader/commit/d19ee2d))

- Reference issue https://nodesecurity.io/advisories/535


<a name="0.5.9"></a>
## [0.5.9](https://github.com/webpack/url-loader/compare/v0.5.8...v0.5.9) (2017-06-12)

14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -38,10 +38,10 @@ module.exports = {
test: /\.(png|jpg|gif)$/,
use: [
{
loader: 'url-loader'
loader: 'url-loader',
options: {
limit: 8192
}
}
}
]
}
@@ -56,11 +56,12 @@ module.exports = {
|:--:|:--:|:-----:|:----------|
|**`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|
|**`fallback`**|`{String}`|`file-loader`|Specify `loader` for the file when file is greater than the limit (in bytes)|

### `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.
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.
You can use other loader using `fallback` option.

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

@@ -88,13 +89,14 @@ Set the MIME type for the file. If unspecified the file extensions will be used
}
```

### `prefix`
### `fallback`

**webpack.config.js**
```js
{
loader: 'url-loader',
options: {
prefix: 'img'
fallback: 'responsive-loader'
}
}
```
38 changes: 22 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
@@ -3,32 +3,38 @@
Author Tobias Koppers @sokra
*/
var loaderUtils = require("loader-utils");
var validateOptions = require("schema-utils");

var mime = require("mime");

module.exports = function(content) {
this.cacheable && this.cacheable();
this.cacheable && this.cacheable();

var options = loaderUtils.getOptions(this) || {};
// Options `dataUrlLimit` is backward compatibility with first loader versions
var limit = options.limit || (this.options && this.options.url && this.options.url.dataUrlLimit);
var options = loaderUtils.getOptions(this) || {};

if(limit) {
limit = parseInt(limit, 10);
}
validateOptions(require("./options"), options, "URL Loader")
// Options `dataUrlLimit` is backward compatibility with first loader versions
var limit = options.limit || (this.options && this.options.url && this.options.url.dataUrlLimit);

var mimetype = options.mimetype || options.minetype || mime.lookup(this.resourcePath);
if(limit) {
limit = parseInt(limit, 10);
}

// No limits or limit more than content length
if(!limit || content.length < limit) {
if(typeof content === "string") {
content = new Buffer(content);
}
return "module.exports = " + JSON.stringify("data:" + (mimetype ? mimetype + ";" : "") + "base64," + content.toString("base64"));
var mimetype = options.mimetype || options.minetype || mime.lookup(this.resourcePath);

// No limits or limit more than content length
if(!limit || content.length < limit) {
if(typeof content === "string") {
content = new Buffer(content);
}

var fileLoader = require("file-loader");
return "module.exports = " + JSON.stringify("data:" + (mimetype ? mimetype + ";" : "") + "base64," + content.toString("base64"));
}

var fallback = options.fallback || "file-loader";
var fallbackLoader = require(fallback);

return fileLoader.call(this, content);
return fallbackLoader.call(this, content);
}

module.exports.raw = true;
18 changes: 18 additions & 0 deletions options.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"type": "object",
"properties": {
"limit": {
"type": "number"
},
"prefix": {
"type": "string"
},
"mimetype": {
"type": "string"
},
"encoding": {
"type": "string"
}
},
"additionalProperties": false
}
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "url-loader",
"version": "0.5.9",
"version": "0.6.0",
"author": "Tobias Koppers @sokra",
"description": "url loader module for webpack",
"license": "MIT",
@@ -9,7 +9,8 @@
},
"dependencies": {
"loader-utils": "^1.0.2",
"mime": "1.3.x"
"mime": "^1.4.1",
"schema-utils": "^0.3.0"
},
"devDependencies": {
"standard-version": "^4.0.0"
@@ -19,6 +20,10 @@
},
"repository": {
"type": "git",
"url": "git@github.com:webpack/url-loader.git"
}
"url": "git+https://github.com/webpack-contrib/url-loader.git"
},
"bugs": {
"url": "https://github.com/webpack-contrib/url-loader/issues"
},
"homepage": "https://github.com/webpack-contrib/url-loader"
}