abpetkov / switchery

iOS 7 style switches for your checkboxes
http://abpetkov.github.io/switchery/
2.06k stars 477 forks source link

Switchery is not defined, require() with webpack #176

Closed alexis-riot closed 4 years ago

alexis-riot commented 4 years ago

Hello,

I try to import Switchery from node_modules (using NPM). I do this code:

try {

    window.$ = window.jQuery = require('jquery');
    window.Popper = require('popper.js').default;
    require('bootstrap');
    require('imports-loader');
    require('jquery-slimscroll');
    require('switchery/standalone/switchery');

    require('./vendor/core');

vendor/core.js:

    var setting_first = document.querySelector('.js-switch-setting-first');
    var switchery = new Switchery(setting_first, { color: '#0080ff', size: 'small' });

But this is not working. It return me an error:

Uncaught ReferenceError: Switchery is not defined