Owlcarousel2: Window binding (window.Zepto || window.jQuery) prevents from https://github.com/webpack/imports-loader usage

Created on 15 May 2016  路  7Comments  路  Source: OwlCarousel2/OwlCarousel2

Most helpful comment

Installation guide is not correct!!
The one and the only way to make it work with Webpack:

import $ from 'jquery';
import 'owl.carousel/dist/assets/owl.carousel.css';
import 'owl.carousel/dist/assets/owl.theme.default.css';

window.jQuery = $;
require('owl.carousel');

All 7 comments

Hi @nikolaybobrovskiy - Can you give any details on how to fix this?

Can Zepto || jQuery (without window.) condition be used?

This would be solved by this PR, which makes the module UMD-compliant: #1048

@foundryspatial-duncan and? How should I solve this issue temporary?

Upd.: Seems okay with import 'imports?window.jQuery=jquery!owl.carousel';

Installation guide is not correct!!
The one and the only way to make it work with Webpack:

import $ from 'jquery';
import 'owl.carousel/dist/assets/owl.carousel.css';
import 'owl.carousel/dist/assets/owl.theme.default.css';

window.jQuery = $;
require('owl.carousel');

I think the last 2 line could be replaced with

import 'imports?jQuery=jquery!own.carousel';

Got simmilar issue. I am trying to load owl with webpack:

            plugins: [
                new webpack.ProvidePlugin({
                    $: 'jquery',
                    jQuery: 'jquery'
                }),
                new webpack.ProvidePlugin({
                    owlCarousel: 'owl.carousel'
                }),
            ],
            module: {
                loaders: [
                    {
                        test: require.resolve('owl.carousel'),
                        loader: "imports-loader?jQuery=jquery"
                    }
                ]
            },

I get an error:
Uncaught TypeError: Cannot read property 'fn' of undefined at:
$.fn.owlCarousel = function

The only way to load the plugin is the one mentioned by @Disorrder that is to use in a module explicitly:

window.jQuery = $;
require('owl.carousel');
Was this page helpful?
0 / 5 - 0 ratings

Related issues

edelworksgithub picture edelworksgithub  路  4Comments

garethjenkinsit picture garethjenkinsit  路  4Comments

hopea114y picture hopea114y  路  3Comments

mkraha picture mkraha  路  4Comments

ghost picture ghost  路  3Comments