Skip to content
This repository has been archived by the owner on Sep 15, 2023. It is now read-only.

Not bundle jquery in production #570

Open
baglio opened this issue Jan 23, 2019 · 1 comment
Open

Not bundle jquery in production #570

baglio opened this issue Jan 23, 2019 · 1 comment
Assignees

Comments

@baglio
Copy link

baglio commented Jan 23, 2019

I develope websites running on Wordpress, where jquery is already loaded, thus I'd like to avoid the redundancy of loading it another time bundled in my app.js.

The Webpack documentation suggests to use externals to load external libraries like so:

module.exports = {
  //...
  externals: {
    jquery: 'jQuery'
  }
};

and then import $ before my code like so:

import $ from 'jquery';

$('.my-element').animate(/* ... */);

I tried to add the first piece of code in task-config.js, but webpack failed to compile with the following error:

Module not found: Error: Can't resolve 'jquery' in
'/Users/myhome/Desktop/nojquery/src/javascripts/modules'

I'm certainly making something wrong here. Would you please help me?

@olets
Copy link
Contributor

olets commented May 28, 2019

@baglio sorry for the slow response!

If you haven't solved this, please try this provide solution in your task-config.js javascript config:

    provide: {
      $: "jquery",
      jQuery: "jquery"
    }

@olets olets self-assigned this May 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants