Skip to content

Commit

Permalink
fix(esbuild): add missing resolveDir to support webfont bundling (#789)
Browse files Browse the repository at this point in the history
When attempting to bundle a font before, esbuild would complain:
> linaria:App_hash.linaria.css:1:46: error: Could not resolve "./font.ttf" (the plugin "linaria" didn't set a resolve directory)
    1 ? @font-face{font-family:"font";src:url("./font.ttf");}...

With this fix the resolveDir is set to the basedir of the file loading
the font (or other external asset) and thus relative paths should work
just fine.

Note: When testing this configure the esbuild build to include the
appropriate loader, e.g.:
    loader: { ".ttf": "dataurl" },
  • Loading branch information
dfrkp authored Jul 11, 2021
1 parent e92bcd9 commit 45e5de0
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions packages/esbuild/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default function linaria({
return {
contents: cssLookup.get(args.path),
loader: 'css',
resolveDir: path.basename(args.path),
};
});

Expand Down

0 comments on commit 45e5de0

Please sign in to comment.