Open baglio opened 5 years ago
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 $
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:
task-config.js
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?
@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
javascript
provide: { $: "jquery", jQuery: "jquery" }
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:
and then
import $
before my code like so:I tried to add the first piece of code in
task-config.js
, but webpack failed to compile with the following error:I'm certainly making something wrong here. Would you please help me?