-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Hashes or queries in imports #862
Comments
Did you perhaps forget to add |
Yes, I added it now. Sorry about that! |
When I run that I get lots of errors that look like this:
But this is just because no loader has been configured for that file type. If you add something like this: const esbuild = require('esbuild');
esbuild.build({
entryPoints: ['index.js'],
bundle: true,
outfile: 'bundle.js',
+ loader: {
+ '.eot': 'file',
+ '.woff': 'file',
+ '.woff2': 'file',
+ '.svg': 'file',
+ '.ttf': 'file',
+ },
}).catch((e) => console.error(e.message)); then the files load fine and preserve the query/hash in the imports: /* ... in bundle.css */
@font-face {
font-family: "Font Awesome 5 Brands";
font-style: normal;
font-weight: 400;
font-display: block;
src:
url(fa-brands-400.F47772JC.eot);
src:
url(fa-brands-400.F47772JC.eot?#iefix) format("embedded-opentype"),
url(fa-brands-400.TY2VVPNB.woff2) format("woff2"),
url(fa-brands-400.GCVJUSS7.woff) format("woff"),
url(fa-brands-400.DV4GNJY3.ttf) format("truetype"),
url(fa-brands-400.HDM7XGLW.svg#fontawesome) format("svg");
} This is expected because the feature to preserve the query/hash was recently added to fix #826. Is there more information required to reproduce your issue? |
Wow, I hadn't realized there were 4 releases, since I tried it out last week. It is good to know that esbuild itself supports this. I actually have the loaders in my main project, but forgot it in the reproducing code. Thanks for your amazing work and quick help! Anyways, my main code uses less stylesheets and uses the |
No, I think this is a bug in esbuild. The problem appears to be that while esbuild supports hashes or queries in imports, that's currently only the case for paths other than absolute paths. It's not working in this case because your setup is using absolute paths. I believe the fix is that esbuild needs to be doing this for absolute paths too. |
For me I have issues even using a file loader or dataURL. All the paths are relative in the scss but seem to become absolute and I think the backslashes all get deleted (
|
The tool you are using to generate that file likely wasn't built to handle Windows-style paths. In CSS, |
I am using the font awesome icons for my project. The module provided css file uses hashes (e.g.
url("../webfonts/fa-solid-900.svg#fontawesome")
) and querystrings (e.g.url("../webfonts/fa-solid-900.eot?#iefix")
) in the font imports. Esbuild doens't resolve those.I think the expected behavior would be to ignore both hash and querystring parts of a URL when resolving, but keeping them in the output css. This is also how webpack handles it.
I made a small repo to reproduce the issue: https://github.com/normanrz/esbuild-sass-bug/tree/esbuild
Note the
esbuild
branch. Run withyarn install && node build.js
The text was updated successfully, but these errors were encountered: