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

Exposing jQuery to window #4

Closed
tb opened this issue Aug 16, 2015 · 2 comments
Closed

Exposing jQuery to window #4

tb opened this issue Aug 16, 2015 · 2 comments

Comments

@tb
Copy link

tb commented Aug 16, 2015

I have trouble to get jQuery exposed to window. This does not work. I tried in to use ProvidePlugin described on http://webpack.github.io/docs/shimming-modules.html on but it did not work in demo09.

plugins: [
  //...
  new webpack.ProvidePlugin({
      $: "jquery",
      jQuery: "jquery",
      "window.jQuery": "jquery"
  })
]
@tb
Copy link
Author

tb commented Aug 16, 2015

Ok, got it working with:

module: {
  loaders: [
    { test: require.resolve("jquery"), loader: "expose?jquery" }
  ]
}

Anyway, it would be cool if you add some example on that case :)

@ruanyf
Copy link
Owner

ruanyf commented Aug 16, 2015

It worked for me.

// webpack.config.js
var webpack = require('webpack');

module.exports = {
  entry: {
    app: './main.js'
  },
  output: {
    filename: 'bundle.js'
  },
  plugins: [
    new webpack.ProvidePlugin({
      $: "jquery",
      jQuery: "jquery",
      "window.jQuery": "jquery"
    })
  ]
};

I will add the case into README.

@ruanyf ruanyf closed this as completed Aug 16, 2015
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