question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[webpack | slick-carousel] Webpack cannot find properly path for slick files

See original GitHub issue

Hello guys, I started to using a webpack bundler, and i got a little issue with slick slider. Slick fonts and gif doesn’t load properly

screenshot of error It looks like webpack skips main folder, where my project is, and looking for files in d:/node_modules instead of d:/main_folder/node_modules I was trying to fix this by creating slick-fix.scss and set font and loader path but i doesn’t work properly slick-fix.scss $slick-loader-path: "/node_modules/slick-carousel/slick/" !default; $slick-font-path: "/node_modules/slick-carousel/slick/fonts/" !default;

main.scss imports @import "slick-fix"; @import "~slick-carousel/slick/slick.scss"; @import "~slick-carousel/slick/slick-theme.scss";

main.js require('./styles/main.scss'); require('jquery'); import 'slick-carousel/slick/slick'; $('.slider').slick();

webpack.config.js is on jsfiddle, because of better readability. I hope that ill got any respond, thanks in advance

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

1reaction
szegheocommented, Dec 8, 2021

It’s working for me using

  • slick-carousel 1.8.1
  • webpack 5.64.4 (using Asset Modules to export files instead file-loader)
  • sass 1.32.13
  • sass-loader 12.3.0

both of these ways:

$slick-loader-path: "~slick-carousel/slick/";
$slick-font-path: "~slick-carousel/slick/fonts/";
@import "~slick-carousel/slick/slick";
@import "~slick-carousel/slick/slick-theme";
$slick-loader-path: "/node_modules/slick-carousel/slick/";
$slick-font-path: "/node_modules/slick-carousel/slick/fonts/";
@import "slick-carousel/slick/slick";
@import "slick-carousel/slick/slick-theme";

…so I think this issue is related to Webpack configuration, not Slick.

If you run into this issue, I recommend you to

  • be sure that the path value assigned to the variable has a trailing slash
  • play with resolve.roots option of Webpack and try to set it to your project root (where your node_modules folder is) as an absolute path
  • also check out the resolve.modules option of Webpack
  • in case if your Webpack config is using the resolve-url-loader package that can also lead to this issue because it can overwrite the default module resolution logic of Webpack
0reactions
mariogmzcommented, May 12, 2020

I’m using laravel mix as a webpack wrapper, I needed to copy both fonts and loader image to my project’s assets and then use my own asset URLs in the slick sass variables.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack cannot find properly path for slick files - Stack Overflow
You cannot access local paths from your http server. In other words, you cannot load files from your harddrive directly.
Read more >
cannot find module 'vuex' or its corresponding type declarations
I re-installed every package changed many settings but it still fails to load all paths and show the error above for all files....
Read more >
How to configure Webpack 4 or 5 from scratch for a basic ...
Webpack will bundle all JavaScript into this file output: { path: path.resolve(__dirname, 'dist'), publicPath: '', filename: 'bundle.js' } ...
Read more >
How we switched from Sprockets to Webpacker - rossta.net
webpack recognizes both AMD define and CommonJs style require to resolve modules. Since slick-carousel imports jQuery , as seen in the except ...
Read more >
How To Use Slick To Create A Carousel | Dilshan Kelsen
First, you can insert the relevant CSS and JavaScript files into your HTML page the same way as in the previous section. Only...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found