diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6746e8d..43efc7d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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.
+
+## [1.1.11](https://github.com/webpack/file-loader/compare/v1.1.10...v1.1.11) (2018-03-01)
+
+
+### Reverts
+
+* **index:** `context` takes precedence over `issuer.context` (`options.useRelativePath`) ([#260](https://github.com/webpack/file-loader/issues/260)) ([e73131f](https://github.com/webpack/file-loader/commit/e73131f))
+
+
+
## [1.1.10](https://github.com/webpack/file-loader/compare/v1.1.9...v1.1.10) (2018-02-26)
diff --git a/package-lock.json b/package-lock.json
index 57c0de8..53ffe1d 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "file-loader",
- "version": "1.1.10",
+ "version": "1.1.11",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
diff --git a/package.json b/package.json
index 4535bab..1e05940 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "file-loader",
- "version": "1.1.10",
+ "version": "1.1.11",
"author": "Tobias Koppers @sokra",
"description": "file loader module for webpack",
"license": "MIT",
diff --git a/src/index.js b/src/index.js
index 0e144fe..62a0297 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,3 +1,6 @@
+/* eslint-disable
+ multiline-ternary,
+*/
import path from 'path';
import loaderUtils from 'loader-utils';
import validateOptions from 'schema-utils';
@@ -31,13 +34,15 @@ export default function loader(content) {
if (options.useRelativePath) {
const filePath = this.resourcePath;
- const issuerContext = context || (
- this._module &&
- this._module.issuer &&
- this._module.issuer.context
- );
+ const issuer = options.context
+ ? context
+ : (
+ this._module &&
+ this._module.issuer &&
+ this._module.issuer.context
+ );
- const relativeUrl = issuerContext && path.relative(issuerContext, filePath)
+ const relativeUrl = issuer && path.relative(issuer, filePath)
.split(path.sep)
.join('/');
diff --git a/test/fixtures/nested/file.png b/test/fixtures/nested/assets/file.png
similarity index 100%
rename from test/fixtures/nested/file.png
rename to test/fixtures/nested/assets/file.png
diff --git a/test/fixtures/fixture-nested.js b/test/fixtures/nested/fixture.js
similarity index 53%
rename from test/fixtures/fixture-nested.js
rename to test/fixtures/nested/fixture.js
index bd8db2f..af5f4ed 100644
--- a/test/fixtures/fixture-nested.js
+++ b/test/fixtures/nested/fixture.js
@@ -1,4 +1,4 @@
/* eslint-disable */
-import png from './nested/file.png';
+import png from './assets/file.png';
export default png;
diff --git a/test/options/__snapshots__/useRelativePath.test.js.snap b/test/options/__snapshots__/useRelativePath.test.js.snap
index 08bd912..698b5f9 100644
--- a/test/options/__snapshots__/useRelativePath.test.js.snap
+++ b/test/options/__snapshots__/useRelativePath.test.js.snap
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`Options useRelativePath \`false\` 1`] = `
+exports[`Options useRelativePath {Boolean} - \`false\` 1`] = `
Object {
"assets": Array [
"9c87cbf3ba33126ffd25ae7f2f6bbafb.png",
@@ -9,29 +9,29 @@ Object {
}
`;
-exports[`Options useRelativePath \`true\` 1`] = `
+exports[`Options useRelativePath {Boolean} - \`true\` 1`] = `
Object {
"assets": Array [
- "nested/9c87cbf3ba33126ffd25ae7f2f6bbafb.png",
+ "assets/9c87cbf3ba33126ffd25ae7f2f6bbafb.png",
],
- "source": "module.exports = __webpack_public_path__ + \\"nested/9c87cbf3ba33126ffd25ae7f2f6bbafb.png\\";",
+ "source": "module.exports = __webpack_public_path__ + \\"assets/9c87cbf3ba33126ffd25ae7f2f6bbafb.png\\";",
}
`;
-exports[`Options useRelativePath \`true\` with absolute \`context\` 1`] = `
+exports[`Options useRelativePath {Boolean} - \`true\` with absolute \`context\` 1`] = `
Object {
"assets": Array [
- "file-loader/test/fixtures/nested/9c87cbf3ba33126ffd25ae7f2f6bbafb.png",
+ "file-loader/test/fixtures/nested/assets/9c87cbf3ba33126ffd25ae7f2f6bbafb.png",
],
- "source": "module.exports = __webpack_public_path__ + \\"file-loader/test/fixtures/nested/9c87cbf3ba33126ffd25ae7f2f6bbafb.png\\";",
+ "source": "module.exports = __webpack_public_path__ + \\"file-loader/test/fixtures/nested/assets/9c87cbf3ba33126ffd25ae7f2f6bbafb.png\\";",
}
`;
-exports[`Options useRelativePath \`true\` with relative \`context\` 1`] = `
+exports[`Options useRelativePath {Boolean} - \`true\` with relative \`context\` 1`] = `
Object {
"assets": Array [
- "9c87cbf3ba33126ffd25ae7f2f6bbafb.png",
+ "assets/9c87cbf3ba33126ffd25ae7f2f6bbafb.png",
],
- "source": "module.exports = __webpack_public_path__ + \\"9c87cbf3ba33126ffd25ae7f2f6bbafb.png\\";",
+ "source": "module.exports = __webpack_public_path__ + \\"assets/9c87cbf3ba33126ffd25ae7f2f6bbafb.png\\";",
}
`;
diff --git a/test/options/useRelativePath.test.js b/test/options/useRelativePath.test.js
index 83633a6..d8cc429 100644
--- a/test/options/useRelativePath.test.js
+++ b/test/options/useRelativePath.test.js
@@ -5,7 +5,7 @@ import webpack from '../helpers/compiler';
describe('Options', () => {
describe('useRelativePath', () => {
- test('`false`', async () => {
+ test('{Boolean} - `false`', async () => {
const config = {
loader: {
test: /(png|jpg|svg)/,
@@ -15,13 +15,13 @@ describe('Options', () => {
},
};
- const stats = await webpack('fixture-nested.js', config);
+ const stats = await webpack('nested/fixture.js', config);
const { assets, source } = stats.toJson().modules[1];
expect({ assets, source }).toMatchSnapshot();
});
- test('`true`', async () => {
+ test('{Boolean} - `true`', async () => {
const config = {
loader: {
test: /(png|jpg|svg)/,
@@ -31,13 +31,13 @@ describe('Options', () => {
},
};
- const stats = await webpack('fixture-nested.js', config);
+ const stats = await webpack('nested/fixture.js', config);
const { assets, source } = stats.toJson().modules[1];
expect({ assets, source }).toMatchSnapshot();
});
- test('`true` with relative `context`', async () => {
+ test('{Boolean} - `true` with relative `context`', async () => {
const config = {
loader: {
test: /(png|jpg|svg)/,
@@ -48,13 +48,13 @@ describe('Options', () => {
},
};
- const stats = await webpack('fixture-nested.js', config);
+ const stats = await webpack('nested/fixture.js', config);
const { assets, source } = stats.toJson().modules[1];
expect({ assets, source }).toMatchSnapshot();
});
- test('`true` with absolute `context`', async () => {
+ test('{Boolean} - `true` with absolute `context`', async () => {
const config = {
loader: {
test: /(png|jpg|svg)/,
@@ -65,7 +65,7 @@ describe('Options', () => {
},
};
- const stats = await webpack('fixture-nested.js', config);
+ const stats = await webpack('nested/fixture.js', config);
const { assets, source } = stats.toJson().modules[1];
expect({ assets, source }).toMatchSnapshot();