Answer the question
In order to leave comments, you need to log in
How to import Swiper with Webpack?
I try to add the Swiper library in this way:
There are no errors, the js-module is added, but for some reason the css is missing.
In webpack.config.js:import Swiper from 'swiper';
module: {
rules: [
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
use: [
{
loader: 'css-loader',
options: {
modules: false
}
},
{ loader: 'postcss-loader' }
],
fallback: 'style-loader'
})
}
]
},
plugins: [
new ExtractTextPlugin({
filename: "./styles/[name].css",
disable: process.env.NODE_ENV === "development"
})
]
};
ERROR in ./node_modules/css-loader??ref--0-2!./node_modules/postcss-loader/lib!./app/styles/main.css
Module build failed: Error: Failed to find 'swiper'
Answer the question
In order to leave comments, you need to log in
Everything is correct. CSS needs to be imported separately. in js.
import Swiper from 'swiper';
import '../node_modules/swiper/dist/css/swiper.css';
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question