Parcel: Imported image paths during development

Created on 7 Dec 2017  Â·  12Comments  Â·  Source: parcel-bundler/parcel

I am having issues with image asset paths during development and production.

During dev, if i do import logo from './logo.svg this becomes => 1230981023.png.
During build, import logo from './logo.svg this becomes => /dist/1230981023.png.

This may have to do with a public URL issue during dev but i'm not sure.

Good First Issue Bug Help Wanted

Most helpful comment

All 12 comments

I had the same issue with importing assets (jpg|svg), but after fiddling with the --public-url it worked out just fine. Perhaps you can share some of your project structure?

Should be fixed by https://github.com/parcel-bundler/parcel/pull/160. You just need to set --public-url when building for prod.

I think I'm having the same issue using Parcel 1.2.1 development server (parcel src/index.html). My imported url (import image from './path/to/image.jpg';) is /24e15f924c17a873dc81435468e5287b.jpg, while it would need to be /dist/24e15f924c17a873dc81435468e5287b.jpg to work.

I have an issue here with a path that is correct for importing an image

screen shot 2019-01-24 at 11 53 42

I have an issue here with a path that is correct for importing an image

Does it build/run correctly?
Then it's only TypeScript not recognizing it, does this fix work: https://github.com/Microsoft/TypeScript-React-Starter/issues/12#issuecomment-326370098

It builds but i get

⠧ Building SpaceInvaders.ts...🚨 /Users/nikos/WebstormProjects/youtube-space-invaders/src/SpaceInvaders.ts(14,21)
Cannot find module './images/backgrounds/sunrise.jpg'.
13 |

14 | import sunrise from './images/backgrounds/sunrise.jpg'
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15 |

⠴ Packaging...🚨 /Users/nikos/WebstormProjects/youtube-space-invaders/src/SpaceInvaders.ts(14,21)
Cannot find module './images/backgrounds/sunrise.jpg'.
13 |

14 | import sunrise from './images/backgrounds/sunrise.jpg'
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15 |

✨ Built in 2.81s.

the image is never attempted to be loaded at runtime

@QuantumInformation ~Please open a new issue that importing raw files (or at least images) can't be imported in typescript.~
Is this again caused by parcel-plugin-typescript?

I updated parcel, issue went away, but now I get this

Server running at http://localhost:1234
🚨 /Users/nikos/WebstormProjects/youtube-space-invaders/src/SpaceInvaders.ts:18:7: Support for the experimental syntax 'exportDefaultFrom' isn't currently enabled (18:8):
16 | import { Interpreter } from './agent/Interpreter'
17 |

18 | export enum Actions {
| ^

Again, it this with parcel-plugin-typescript?

Was this page helpful?
0 / 5 - 0 ratings