Hi I’m using sage 10 and added slick-carousel and react-slick.
I’ve added react-slick and slick-carousel packages by using yarn
yarn add react-slick
yarn add slick-carousel
and then imported required css files like this:
import "slick-carousel/slick/slick.css";
import "slick-carousel/slick/slick-theme.css";
When I add import statements for importing slick css, yarn build command throws an error: Module parse failed: Unexpected character ‘@’. This issue happens only when I’m importing external css file inside a js file. You can see the error message below.
╭ sage [82619ef58ee50380] ./public
│
│ │ Module parse failed: Unexpected character '@' (1:0)
│ │
│ │ > @charset 'UTF-8';
│ │ | /* Slider */
│ │ | .slick-loading .slick-list
│
I found resources on stackoverflow(sass - Webpack 5 error "Uncaught Error: Module parse failed: Unexpected character '@'" when loading fonts - Stack Overflow) but there are some modifications is needed in webpack config file and In my setup of sage10 I can’t find any webpack config file. Do I need to create this manually?
I found one resource here as well https://discourse.roots.io/t/import-css-module/22262 but it says import CSS to app.css file. What if someone wants to import that particular CSS for a specific component instead importing it for complete app?
Even when we add these css files in app.css it throws and build warnings:
│ │ Module Warning (from ../node_modules/postcss-loader/dist/cjs.js):
│ │ (6:1) from "postcss-import" plugin: @import must precede all other statements (besides @charset or empty @layer)
│ │ Code:
│ │ @import 'aos/dist/aos.css'
│
│ │ Module Warning (from ../node_modules/postcss-loader/dist/cjs.js):
│ │ (20:1) from "postcss-import" plugin: @import must precede all other statements (besides @charset or empty @layer)
│ │ Code:
│ │ @import 'slick-carousel/slick/slick.css'
Using the following versions:
Sage 10.7.0
“slick-carousel”: “^1.8.1”
“react-slick”: “^0.29.0”
“yarn”:“1.22.21”
Any help or workaround is much appreciated. Thanks!