Omar Awamry
Omar Awamry

Reputation: 1619

Webpack 3 'Uncaught ReferenceError: jquery is not defined'

I'm trying to add jQuery in the bundle, so far webpack 3 is not making it easy, i've seen the question asked several times, and none of the answers worked.

I added all the parts that are supposed to make this work

In webpack.config.js

  externals: {
    jquery: 'jQuery'
  },
  plugins: [
    new webpack.DefinePlugin({
      '$': 'jquery',
      'jQuery': 'jquery',
      'window.jQuery': 'jquery'
    })
  ]

In entry file: app.jsx

window.$ = window.jQuery = require("jquery");

Webpack compiles, but in the browser I get the same error enter image description here

Here's the repo, incase anyone wanna take a look at the files

Thanks alot in advance :)

Upvotes: 0

Views: 1162

Answers (1)

Kreozot
Kreozot

Reputation: 1576

You need to use ProvidePlugin, not DefinePlugin. And also remove "externals" section.

Upvotes: 1

Related Questions