Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

152
Visualizações
Can't import CSS from Swiper using Webpack with error "Module parse failed: Unexpected character '@' You may need an appropriate loader"

I have a project using SCSS. In this project a minified CSS file is generated during compilation. Now I wanted to add Swiper to the project. So I tried to import the correspodning styles before my styles in index.js. Unfortunately I get an error during compillation:

ERROR in ./node_modules/swiper/swiper-bundle.css 13:0
Module parse failed: Unexpected character '@' (13:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders

This is how my index.js looks:

import 'swiper/swiper-bundle.css';
import '../styles/styles.scss';
import Swiper from 'swiper';

This is how my webpack.config.js looks:

module.exports = {
  entry: './src/js/index.js',

  output: {
    filename: 'bundle.js',
    path: path.resolve(__dirname, 'dist')
  },

  plugins: [
    new MiniCssExtractPlugin({
      filename: 'styles.css'
    }),
  ],

  module: {
    rules: [
      {
        test: /\.s[ac]ss$/i,
        use: [
          MiniCssExtractPlugin.loader,
          {
            loader: 'css-loader',
            options: {
              url: false,
            },
          },
          {
            loader: 'sass-loader',
            options: {
              sourceMap: true,
            },
          },
        ],
      },
    ],
  },
};

What do I need to change in order to make it work?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Check if you have node_modules excluded in your webpack config. That fixed it for me.

about 4 years ago · Juan Pablo Isaza Relatório

0

Try adding following code to the webpack.config.js file:

{
    test: /\.css$/,
    use: [ 'style-loader', 'css-loader' ]
 }

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda