Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Font url broken when using a directory name for both assetNames and entryNames #1658

Closed
ArnaudBarre opened this issue Oct 5, 2021 · 2 comments

Comments

@ArnaudBarre
Copy link

Goal: I try to mimic Vite output structure

Config:

esbuild.build({
    entryPoints: ["src/index.tsx"],
    bundle: true,
    outdir: "build",
    platform: "browser",
    minify: true,
    format: "esm",
    assetNames: "assets/[name].[hash]",
    entryNames: "assets/[name].[hash]",
    loader: {
      ".png": "file",
      ".jpg": "file",
      ".woff2": "file",
    },
});

assets/index.[hash].css contains url(./assets/CooperLtBT-Bold.GLD7FVAK.woff2), which resoles to /assets/assets/CooperLtBT-Bold.GLD7FVAK.woff2 in the browser

@ArnaudBarre
Copy link
Author

This was with esbuild 0.12.8

With 0.13.4, I got no issues with font urls but the relative urls doesn't work well when the page doesn't load on the root path.

I finally got the setup I wanted with a cleaner config:

esbuild.build({
  outdir: "build/assets",
  publicPath: "/assets/",
  assetNames: "[name].[hash]",
  entryNames: "[name].[hash]",
  // ...other options
});

@evanw
Copy link
Owner

evanw commented Oct 6, 2021

Yes, this was fixed in June: #1044. And publicPath is the correct solution here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants