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

390
Visualizações
Swiper 8 with Webpack 5: Class not defined

I'm trying to use Swiper 8 with Webpack 5.

In my Webpack config i defined two entry points:

module.exports = {
    entry: {
        vendor: './vendor.js',
        frontend: './frontend.js',
    }
    ...
}

In the vendor.js I've imported Swiper:

import 'swiper/scss';
import Swiper from 'swiper';

In the frontend.js I've imported my script files:

import './custom.js'

No i try to initalize Swiper in my custom.js:

const swiper = new Swiper('.swiper', {});

Here I get an error message:

Uncaught ReferenceError: Swiper is not defined

In my HTML file, I import the vendor.js before the frontend.js file. Theoretically, the Swiper class should be available to me. What am I doing wrong?

<script type="text/javascript" src="/dist/vendor.js"></script>
<script type="text/javascript" src="/dist/frontend.js"></script>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You will need to

import Swiper from 'swiper';

inside your custom.js, because, even though it is properly imported in frontend.js, it's not imported in custom.js and it is not seen there.

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