webpack: Support for default loader (file-loader) for unknown modules
Feature request
from https://github.com/facebook/create-react-app/issues/667#issuecomment-252262349:
A catchall unknown-source loader feels like it would be pretty beneficial. My opinion is that you want it managed by webpack in some way or another.
What is the expected behavior?
Non-javascript files without loader will be handled by file-loader
, this can be configured in module.fallbackLoader
.
What is motivation or use case for adding/changing the behavior?
Nowadays you need to list all of extensions yourself:
{
test: /\.(json|css|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$/,
loader: "file-loader",
}
How should this be implemented in your opinion?
// webpack.config.js
module.exports = {
module: {
fallbackLoader: {
loader: "url-loader",
}
}
}
Are you willing to work on this yourself? yes
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 17 (13 by maintainers)
make sense, now it works, that solves problem for me, thanks for help, final config:
Webpack block
While I think it makes more sense to list all extensions explicitly you can do a
default
loaders with theoneOf
construct inmodule.rules
:https://webpack.js.org/configuration/module/#rule-oneof
Should this be considered as a separate module type also? Something we may want to consider if no loaders applied.