Answer the question
In order to leave comments, you need to log in
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();
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
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 questionAsk a Question
731 491 924 answers to any question