kazijawad / esbuild-plugin-svgr

An esbuild plugin for importing SVGs as React components.
https://npmjs.com/package/esbuild-plugin-svgr
MIT License
36 stars 12 forks source link

SVG paths are not resolved #12

Open alexandernst opened 1 year ago

alexandernst commented 1 year ago

I have a scss file that looks like this:

index.scss

body {
  background-image: url(@src/logo.svg);
}

When I build the project, the resulting css file will contain the same @src/logo.svg url, which is invalid.

Note that I have configured esbuild and the sassPlugin to resolve @src to the correct path.

Also note that a similar thing happens in the following case:

index.jsx

import Logo from "@src/logo.svg?url";

The resulting index.js file will contain @src/logo.svg (which is incorrect).

The correct behaviour would be to resolve the path to its final path. Eg, if my esbuild config is

assetNames: "[dir]/[name].[hash]",

then the url should look like /logo.8Fgx1Fgm.svg