New Asset Modules type: asset/null, to properly replace null-loader
See original GitHub issueFeature request
New asset module type: asset/null
, to properly replace the now deprecated null-loader
What is the expected behavior?
rules: [
...
{
test: /\.css$/,
type: 'asset/null'
}
]
To replace the use of the now deprecated null-loader
in situations analogous to the following
rules: [
...
{
test: /\.css$/,
use: [
{ loader: "null-loader" }
]
}
]
That is: to tell webpack to ignore a module but, instead of based on a name, to ignore a module based on a rule.
What is motivation or use case for adding/changing the behavior?
The documented way to replace the use of null-loader
Setting resolve.alias.package to false will tell webpack@5 to ignore a module.
does not correctly replace the deprecated loader.
In particular, it does not allow webpack to prevent modules from being imported based on a rule, which was one the uses for null-loader
.
Using resolve.alias also implies that the name of the modules to be ignored are known when creating the webpack config, which is not always true or even possible.
How should this be implemented in your opinion?
With the creation of a new type for asset modules: asset/null
.
The change is also consistent with how the other deprecated modules were dealt with
asset/resource
replacedfile-loader
asset/inline
replacedurl-loader
asset/source
replacedraw-loader
With this proposal asset/null
would replace null-loader
Are you willing to work on this yourself?
Yes, if directed to the appropriate parts of the code
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (8 by maintainers)
Top GitHub Comments
Thanks! I can submit a PR for it if you guys want.
Ideally we should not run plugin, just create locals and return them