This repository has been archived by the owner on Mar 17, 2021. It is now read-only.
fix(index): don't concat options.outputPath
and options.publicPath
#246
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ export default function loader(content) { | |
|
||
validateOptions(schema, options, 'File Loader'); | ||
|
||
const context = options.context || this.rootContext || this.options && this.options.context | ||
const context = options.context || this.rootContext || (this.options && this.options.context); | ||
|
||
let url = loaderUtils.interpolateName(this, options.name, { | ||
context, | ||
|
@@ -27,9 +27,8 @@ export default function loader(content) { | |
); | ||
} | ||
|
||
const filePath = this.resourcePath; | ||
|
||
if (options.useRelativePath) { | ||
const filePath = this.resourcePath; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
const issuerContext = (this._module && this._module.issuer | ||
&& this._module.issuer.context) || context; | ||
|
||
|
@@ -44,13 +43,8 @@ export default function loader(content) { | |
} | ||
|
||
url = relativePath + url; | ||
} else if (options.outputPath) { | ||
// support functions as outputPath to generate them dynamically | ||
outputPath = typeof options.outputPath === 'function' ? options.outputPath(url) : options.outputPath + url; | ||
|
||
url = outputPath; | ||
} else { | ||
outputPath = url; | ||
outputPath += url; | ||
} | ||
|
||
let publicPath = `__webpack_public_path__ + ${JSON.stringify(url)}`; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,55 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Options outputPath {Function} 1`] = `"module.exports = __webpack_public_path__ + \\"test/9c87cbf3ba33126ffd25ae7f2f6bbafb.png\\";"`; | ||
exports[`Options outputPath {Function} 1`] = ` | ||
Object { | ||
"assets": Array [ | ||
"output_path/9c87cbf3ba33126ffd25ae7f2f6bbafb.png9c87cbf3ba33126ffd25ae7f2f6bbafb.png", | ||
], | ||
"source": "module.exports = __webpack_public_path__ + \\"9c87cbf3ba33126ffd25ae7f2f6bbafb.png\\";", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add to tests |
||
} | ||
`; | ||
|
||
exports[`Options outputPath {String} 1`] = `"module.exports = __webpack_public_path__ + \\"/test/9c87cbf3ba33126ffd25ae7f2f6bbafb.png\\";"`; | ||
exports[`Options outputPath {Function} with \`publicPath\` {Function} 1`] = ` | ||
Object { | ||
"assets": Array [ | ||
"output_path/9c87cbf3ba33126ffd25ae7f2f6bbafb.png9c87cbf3ba33126ffd25ae7f2f6bbafb.png", | ||
], | ||
"source": "module.exports = \\"public_path/9c87cbf3ba33126ffd25ae7f2f6bbafb.png\\";", | ||
} | ||
`; | ||
|
||
exports[`Options outputPath {Function} with \`publicPath\` {String} 1`] = ` | ||
Object { | ||
"assets": Array [ | ||
"output_path/9c87cbf3ba33126ffd25ae7f2f6bbafb.png9c87cbf3ba33126ffd25ae7f2f6bbafb.png", | ||
], | ||
"source": "module.exports = \\"public_path/9c87cbf3ba33126ffd25ae7f2f6bbafb.png\\";", | ||
} | ||
`; | ||
|
||
exports[`Options outputPath {String} 1`] = ` | ||
Object { | ||
"assets": Array [ | ||
"output_path/9c87cbf3ba33126ffd25ae7f2f6bbafb.png", | ||
], | ||
"source": "module.exports = __webpack_public_path__ + \\"9c87cbf3ba33126ffd25ae7f2f6bbafb.png\\";", | ||
} | ||
`; | ||
|
||
exports[`Options outputPath {String} with \`publicPath\` {Function} 1`] = ` | ||
Object { | ||
"assets": Array [ | ||
"output_path/9c87cbf3ba33126ffd25ae7f2f6bbafb.png", | ||
], | ||
"source": "module.exports = \\"public_path/9c87cbf3ba33126ffd25ae7f2f6bbafb.png\\";", | ||
} | ||
`; | ||
|
||
exports[`Options outputPath {String} with \`publicPath\` {String} 1`] = ` | ||
Object { | ||
"assets": Array [ | ||
"output_path/9c87cbf3ba33126ffd25ae7f2f6bbafb.png", | ||
], | ||
"source": "module.exports = \\"public_path/9c87cbf3ba33126ffd25ae7f2f6bbafb.png\\";", | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,19 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Options publicPath {Function} 1`] = `"module.exports = \\"test/9c87cbf3ba33126ffd25ae7f2f6bbafb.png\\";"`; | ||
exports[`Options publicPath {Function} 1`] = ` | ||
Object { | ||
"assets": Array [ | ||
"9c87cbf3ba33126ffd25ae7f2f6bbafb.png", | ||
], | ||
"source": "module.exports = \\"public_path/9c87cbf3ba33126ffd25ae7f2f6bbafb.png\\";", | ||
} | ||
`; | ||
|
||
exports[`Options publicPath {String} 1`] = `"module.exports = \\"/test/9c87cbf3ba33126ffd25ae7f2f6bbafb.png\\";"`; | ||
exports[`Options publicPath {String} 1`] = ` | ||
Object { | ||
"assets": Array [ | ||
"9c87cbf3ba33126ffd25ae7f2f6bbafb.png", | ||
], | ||
"source": "module.exports = \\"public_path/9c87cbf3ba33126ffd25ae7f2f6bbafb.png\\";", | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just fix
eslint
problem.