feat(index): support fallback loader options (options.fallback
)
#123
Conversation
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.
Very good work! Thanks! Let's add more tests 👍
options: { | ||
limit: 100, | ||
fallback: 'file-loader', | ||
name: '[name].[ext]', |
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.
Let's add tests where name is [hash].[ext]
to ensure options will send in fallback.
src/normalizeFallback.js
Outdated
@@ -0,0 +1,48 @@ | |||
function normalizeFallbackString(fallbackString, originalOptions) { |
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.
Need tests
src/normalizeFallback.js
Outdated
@@ -0,0 +1,48 @@ | |||
function normalizeFallbackString(fallbackString, originalOptions) { | |||
const index = fallbackString.indexOf('?'); | |||
if (index >= 0) { |
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.
Need tests
I've added some tests, @ekulabuhov. Please check it out. |
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.
Good work! Thanks!
options.fallback
)
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.
Sorry for big delay, a lot of work, can you add comments in source why we do delete
?
src/index.js
Outdated
const fallbackLoaderContext = Object.assign({}, this, { | ||
query: fallbackQuery, | ||
}); | ||
delete fallbackLoaderContext.options; |
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.
Why we remove fallbackLoaderContext.options
?
@evilebottnawi No problem. I've added a few comment lines. Let me know whether this works for you. |
src/normalizeFallback.js
Outdated
@@ -0,0 +1,48 @@ | |||
function normalizeFallbackString(fallbackString, originalOptions) { |
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.
Can we move this to src/utils/normalizeFallback.js
, in near future we will release new major version url-loader
with dropping node@4
and merge this PR. Thanks!
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.
It's been moved!
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.
👍
It is now possible to explicitly specify options for the fallback loader. The new definition (schema) for the fallback option is a lighter variant of the one for module.rules.use. See schemas/WebpackOptions.json in the webpack repository.
It is now possible to explicitly specify options for the fallback loader.
The
fallback
option now behaves similar tomodule.rules.use
.This 1.0.1-based configuration…
…can now be written as
And as one would expect, that means options can be provided, as well…
Please look for potential to break existing configurations and surrounding loaders.