How to correctly expose jQuery with Webpack 5?

Viewed 1798

Is there any specific way to expose jQuery with Webpack 5?

It used to work on Webpack 4 OK, with the config bellow, but it shows the Uncaught Reference Error: jQuery is not defined error now with 5.

module: {
    rules: [
      {
        test: require.resolve('jquery'),
        loader: 'expose-loader',
        options: {
          exposes: ['$', 'jQuery'],
        },
      },
0 Answers
Related