I try to connect to the slick project via webpack following the example of the author’s repository.
In this repository slider works.
In my project, there is no way to start, although it seems to be connected in almost the same way (the difference is that the project uses gulp, the webpack is connected through it).
What could be the error? What is worth trying?
Repository from the slider author with a working example
link
Symptoms of the problem
jQuery scripts without using plugins work correctly.
When you connect 'slick-carousel' gives:
Uncaught TypeError: (0 , _jquery2.default)(...).slick is not a function or (if you connect jquery in a webpack globally via ProvidePlugin)
$(...).slick is not a function. App.js code
import $ from 'jquery'; import 'slick-carousel'; $(".slider-wrapper").slick(); Versions of installed dependencies
"devDependencies": { "webpack": "3.4.1", "webpack-stream": "^4.0.0", }, "dependencies": { "jquery": "1.11.1", "slick-carousel": "1.6.0" } Webpack config
const path = require('path'); //npm module for absolute path like path.resolve(__dirname, './build') const config = require('./gulp/config.js'); var webpack = require('webpack'); module.exports = { entry: './'+ config.src.jsEntryPoint, output: { filename: 'bundle.js', path: path.resolve(__dirname, './' + config.dest.js), }, // watch: true, //live-reloading devtool: 'source-map', module: { rules: [ { test: /\.js?$/, loader: "babel-loader" }, { test: require.resolve("jquery"), use: [ { loader: "expose-loader", options: "jQuery" }, { loader: "expose-loader", options: "$" } ] } ] }, }; Config connecting webpack to Gulp
const gulp = require('gulp'); const webpackStream = require('webpack-stream'); const webpack = require('webpack'); const config = require('../config.js'); gulp.task('js-webpack', function() { gulp.src(config.src.jsEntryPoint) .pipe( webpackStream( require('../../webpack.config.js'), webpack )) .pipe(gulp.dest(config.dest.js)); });