F
F
faleaksey2019-02-19 12:14:14
JavaScript
faleaksey, 2019-02-19 12:14:14

How to make jq available from build file in webpack?

How to make jq available from build file in webpack?
I connect to the jq assembly file through

new webpack.ProvidePlugin({
      $: 'jquery',
      jQuery: 'jquery',
      'window.jQuery': 'jquery',
    }),

but at the same time, if I write something in jq in an external file, then $ is not defined.
How to fix? thank)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yura Komarov, 2019-06-21
@Yurajun

In the webpack.config.js settings, you need to add the following code

module: {
  loaders: [
     {
        test: require.resolve('jquery'),
        loader: 'expose?$!expose?jQuery',
     }
  ]
}

And install the "expose-loader" plugin

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question