Git Product home page Git Product logo

Comments (3)

zedtux avatar zedtux commented on July 23, 2024 1

After facing the same kind of issue with the fullcalendar jQuery plugin, banging my head to the wall for few seconds and I found a way to load jQuery plugins using the script-loader and the expose-loader !

The fullcalendar plugin uses jQuery and moment so I had to expose them as global :

environment.loaders.append('jquery', {
  test: require.resolve('jquery'),
  use: [
    {
      loader: 'expose-loader',
      options: 'jQuery'
    },
    {
      loader: 'expose-loader',
      options: '$'
    }
  ]
})

environment.loaders.append('moment', {
  test: require.resolve('moment'),
  use: [
    {
      loader: 'expose-loader',
      options: 'moment'
    }
  ]
})

And then I can load fullcalendar this way :

environment.loaders.append('fullcalendar', {
  test: require.resolve('fullcalendar'),
  loader: 'script-loader?fullcalendar/dist/fullcalendar.js'
})

So I did the same with jquery-minicolors :

environment.loaders.append('jquery-minicolors', {
  test: require.resolve('jquery-minicolors'),
  loader: 'script-loader?jquery-minicolors/jquery.minicolors.js'
})

And It works 🎉.

from jquery-minicolors.

claviska avatar claviska commented on July 23, 2024

I don't usually use jQuery with a module loader, but perhaps the suggestions in this answer will point you in the right direction.

Another thing that may (or may not) help is aliasing window.jQuery like I've seen in a number of Bootstrap projects.

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

Aside from that, I'm not sure as it could be an Angular thing, a Webpack thing, or simply an error in your code. Try logging the value of $ or jQuery where you instantiate and see if they're actually references to jQuery.

from jquery-minicolors.

zedtux avatar zedtux commented on July 23, 2024

Thank you @claviska for your quick response.

I tried everything from the SO question you shared but it didn't worked.
I also tried the alias you gave, but still not working.

From the Chrome console I can access $ and I'm using the fullcalendar package which depends on jQuery so I think jQuery is well configured.

from jquery-minicolors.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.