Webpack 5 and null-loader-esque functionality
Asked Answered
S

1

7

Webpack 5 deprecated null-loader, which was helpful for excluding certain imports from client-side bundles. Now, the docs say that I should use the resolve.alias option with false instead, however, this thing doesn't accept regex keys like null-loader did. But I want to deliberately exclude specific imports matching a regex. I've tried IgnorePlugin, but that simply prevents the module from being added to the bundle but keeps the import, which breaks in the browser.

What's the intended solution here? Should I write my own loader to do what null-loader used to do?

Streamlined answered 18/4, 2021 at 22:25 Comment(0)
O
2

The deprecation note suggests that you can use regex. See xyz$: https://webpack.js.org/blog/2020-10-10-webpack-5-release/#deprecated-loaders

Try wrapping the regex key in single quotes if necessary. This seems to have worked for me.

Ostend answered 8/6, 2021 at 20:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.