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

128
Visualizações
how to properly set up path for assets in esbuild

How should I configure path for assets in esbuild? My current config looks like so:

const esbuild = require("esbuild");

esbuild.build({
  bundle: true,
  entryPoints: ["src/index.tsx"],
  outdir: "public/build",
  splitting: true,
  minify: true,
  sourcemap: true,
  format: "esm",
  inject: ["react-shim.js"],
  loader: {
    ".png": "file",
    ".jpg": "file",
    ".jpeg": "file",
    ".svg": "file",
    ".gif": "file",
  },
  assetNames: "[dir]/[name]",
});

I have my files like so: public -> index.html

In public during the build the "build" folder is created and in there I have assets/ and index.js with main.css, esbuild provides this generic placeholders for dirname and filename that you can see by the assetNames prop, and I am expecting that whatever folder holds those files, would be copied with this same name and appended to the path given in outdir. And this is exactly what is happening, but in the browser in Network tab the path to the asset is "...smth/front/public/assets/cart.svg". Build folder is skipped. And when I try to append it to assetNames like so

assetNames: "build/[dir]/[name]",

Then in the build folder there is another build folder created with assets folder and files. Why is it happening this way and what can I do about it? In case it makes a difference I'm using React 18 and typescript. Thanks

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