B
B
bormor2017-09-16 16:11:30
JavaScript
bormor, 2017-09-16 16:11:30

Webpack 2 and jQuery plugin. How to connect correctly?

I'm trying to connect using ProvidePlugin.
Webpack builds without errors, jQuery works.
But for the plugin it gives an error $(...).slick is not a function.
What else can help in this situation?


Module code

import $ from 'jquery';
import 'slick-carousel';
$(".slider-wrapper").slick();


webpack config code
webpack.config.js

const path = require('path'); //npm module for absolute path like  path.resolve(__dirname, './build')
const webpack = require('webpack');
const WebpackBuildNotifierPlugin = require('webpack-build-notifier');
const config       = require('./gulp/config.js');


module.exports = {
    entry: './'+ config.src.jsEntryPoint,   
    output: {
        filename: 'bundle.js', 
        path: path.resolve(__dirname, './' + config.dest.js),   
    },
    watch: true, //live-reloading
    devtool: 'source-map', 


    plugins: [
        // jQuery globally
        new webpack.ProvidePlugin({ 
            $: "jquery",
            jQuery: "jquery",
            "window.jQuery": "jquery"
        }),
    ],


    // Babel
    module: {
        rules: [{
        test: /\.js$/, 
        exclude: [/node_modules/], 
        use: [{ 
            loader: 'babel-loader',
            options: { presets: ['es2015'] }
        }]
        }]
    }
};

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Pacification, 2017-09-21
@dmitry_pacification

Now there is no way to show the code directly, but I connected it as it is written in the dock for bootstrap 4. Copypaste and it all worked. In the node console, take a look at what needs to be installed if it swears

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question