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

[BUG] the image import path in bundled builds are incorrect #3122

Closed
4 tasks done
cain-wang opened this issue Apr 8, 2021 · 2 comments
Closed
4 tasks done

[BUG] the image import path in bundled builds are incorrect #3122

cain-wang opened this issue Apr 8, 2021 · 2 comments

Comments

@cain-wang
Copy link

cain-wang commented Apr 8, 2021

Bug Report Quick Checklist

  • I am on the latest version of Snowpack & all plugins.
  • I use package manager ____ (Fill in: npm, yarn, pnpm, etc).
  • I run Snowpack on OS ____ (Fill in: Windows, Mac, Linux, etc).
  • I run Snowpack on Node.js v12+

Describe the bug

Snowpack somehow always assume the image paths are from the root level.
If a component not at root level tries to import an image with relative path, the bundled url would be incorrect.

To Reproduce

For instance, in the snowpack typescript react template, if I have a Logo component at src/components/Logo.tsx and have an import statement:

import logo from './img/logo.svg';

Then I build the project with the internal esbuild optimizer:

  optimize: {
    bundle: true,
  },

The bundled /index.js would compile to:

// build/dist/components/Logo.js
import logo from "./img/logo.svg";

Which points to /dist/img/logo.svg instead of /dist/components/img/logo.svg

Expected behavior

The image import should work.

Anything else?

@cain-wang
Copy link
Author

cain-wang commented Apr 16, 2021

I looked into the codebase more and suspect this is related to [BUG] snowpack bundle build generate import statement for images and json files #3109

@cain-wang
Copy link
Author

Duplicate of #3109

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

1 participant