Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolve.alias: document replacement for deprecated null-loader regexp matching #6969

Open
juliangilbey opened this issue Jul 17, 2023 · 1 comment
Assignees

Comments

@juliangilbey
Copy link

The docs say that null-loader is deprecated and gives an example of how to do it:

W> [`null-loader`](https://github.com/webpack-contrib/null-loader) is deprecated in webpack 5. use `alias: { xyz$: false }` or absolute path `alias: {[path.resolve(__dirname, './path/to/module')]: false }`

```js
module.exports = {
//...
resolve: {
alias: {
'ignored-module': false,
'./ignored-module': false,
},
},
};
```

But null-loader can also use regexps to drop files, like this:

module.exports = {
  //...
  module: {
    rules: [
      {
        test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
        use: 'null-loader'
      },
    ]
  },
};

It would be helpful if the resolve.alias documentation could give an example of how to handle such a case. I think that the following would be the appropriate replacement, but I am far from certain that the resolver treats the alias as a regexp:

module.exports = {
  //...
  resolve: {
    alias: {
      '\\.woff2(\\?v=\\d+\\.\\d+\\.\\d+)?$': false,
    },
  },
};
@snitin315 snitin315 self-assigned this Feb 20, 2024
@snitin315
Copy link
Member

resolve.alias doesn't accept RegExp paths

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants