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/file-loader
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.11.0
Choose a base ref
...
head repository: webpack-contrib/file-loader
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.11.1
Choose a head ref
  • 2 commits
  • 4 files changed
  • 2 contributors

Commits on Apr 1, 2017

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    80cdee2 View commit details
  2. chore(release): 0.11.1

    joshwiens committed Apr 1, 2017

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    9afc205 View commit details
Showing with 69 additions and 12 deletions.
  1. +10 −0 CHANGELOG.md
  2. +7 −10 index.js
  3. +1 −1 package.json
  4. +51 −1 test/correct-filename.test.js
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,16 @@

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.11.1"></a>
## [0.11.1](https://github.com/webpack/file-loader/compare/v0.11.0...v0.11.1) (2017-04-01)


### Bug Fixes

* outputPath function overriden by useRelativePath ([#139](https://github.com/webpack/file-loader/issues/139)) ([80cdee2](https://github.com/webpack/file-loader/commit/80cdee2))



<a name="0.11.0"></a>
# [0.11.0](https://github.com/webpack/file-loader/compare/v0.10.1...v0.11.0) (2017-03-31)

17 changes: 7 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
@@ -36,14 +36,6 @@ module.exports = function(content) {
});

var outputPath = "";
if (config.outputPath) {
// support functions as outputPath to generate them dynamically
outputPath = (
typeof config.outputPath === "function"
? config.outputPath(url)
: config.outputPath
);
}

var filePath = this.resourcePath;
if (config.useRelativePath) {
@@ -56,8 +48,13 @@ module.exports = function(content) {
outputPath = relativePath + url;
}
url = relativePath + url;
} else if (outputPath) {
outputPath = outputPath + url;
} else if (config.outputPath) {
// support functions as outputPath to generate them dynamically
outputPath = (
typeof config.outputPath === "function"
? config.outputPath(url)
: config.outputPath + url
);
url = outputPath;
} else {
outputPath = url;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "file-loader",
"version": "0.11.0",
"version": "0.11.1",
"author": "Tobias Koppers @sokra",
"description": "file loader module for webpack",
"files": [
52 changes: 51 additions & 1 deletion test/correct-filename.test.js
Original file line number Diff line number Diff line change
@@ -24,6 +24,29 @@ function run(resourcePath, query, content) {
result: result
}
}
function run_with_options(resourcePath,options, content) {
content = content || new Buffer("1234");
var file = null;

var context = {
resourcePath: resourcePath,
options: {
"fileLoader": options,
context: "/this/is/the/context"
},
emitFile: function(url, content2) {
content2.should.be.eql(content);
file = url;
}
};

var result = fileLoader.call(context, content)

return {
file: file,
result: result
}
}

function test(excepted, resourcePath, query, content) {
run(resourcePath, query, content).file.should.be.eql(excepted);
@@ -86,4 +109,31 @@ describe("useRelativePath option", function() {
'module.exports = __webpack_public_path__ + \"this/81dc9bdb52d04dc20036dbd8313ed055.txt\";'
);
});
});
});
describe("outputPath function", function() {
it("should be supported", function() {
outputFunc = function(value) {
return("/path/set/by/func");

};
var options = {};
options.outputPath = outputFunc;
run_with_options("/this/is/the/context/file.txt", options).result.should.be.eql(
'module.exports = __webpack_public_path__ + \"/path/set/by/func\";'
);

});
it("should be ignored if you set useRelativePath", function() {
outputFunc = function(value) {
return("/path/set/by/func");

};
var options = {};
options.outputPath = outputFunc;
options.useRelativePath = true;
run_with_options("/this/is/the/context/file.txt", options).result.should.be.eql(
'module.exports = __webpack_public_path__ + \"./81dc9bdb52d04dc20036dbd8313ed055.txt\";'
);

});
});