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
Laravel Mix Dynamically Imported JavaScript

In my project, we use Laravel Mix to compile our JavaScript, bundling all the imports into a single file. To improve the organisation of something I'm working on, I've moved some of my JS into separate files and am dynamically importing them when needed.

function registerListeners(type, callback) {
    import(`./extras/${type}`)
        .then(module => {
            module.default({
                callback,
                // some other stuff
            })
        })
}

This all behaves fine and works, however, those dynamically imported files are put in the wrong location.

Currently, my mix config is setup with my primary JavaScript file being built to public/js/app.js

mix.js("resources/assets/js/app.js", "public/js")

The dynamically imported files however get placed directly in the public/ directory with numerical names (e.g. public/0.js, public/1.js, etc.) Is there any way to tell Laravel Mix to place these within the JavaScript directory? I don't need the files merged; as nice as that would be; I just need them in the right space.

We're currently using v4.1.4 of Laravel Mix. We're not looking to upgrade unless it's absolutely necessary.

about 4 years ago · Juan Pablo Isaza
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