HMR: When adding image it tries to parse PNG as JS
See original GitHub issueRepro: Enable HMR, add an image to working tree.
> SyntaxError: /Users/frantic/code/AwesomeProject/js/img/like@2x.png: Unexpected character '�' (1:0)
> > 1 | �PNG
> | ^
> 2 |
> 3 |
> 4 | IHDRP���sRGB��� pHYs
���iTXtXML:com.adobe.xmp<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 5.4.0">
> at Parser.pp.raise (/Users/frantic/code/AwesomeProject/node_modules/babylon/index.js:1378:13)
> at Parser.getTokenFromCode (/Users/frantic/code/AwesomeProject/node_modules/babylon/index.js:5250:10)
> at Parser.readToken (/Users/frantic/code/AwesomeProject/node_modules/babylon/index.js:4887:19)
> at Parser.<anonymous> (/Users/frantic/code/AwesomeProject/node_modules/babylon/index.js:4338:20)
> at Parser.readToken (/Users/frantic/code/AwesomeProject/node_modules/babylon/index.js:3632:22)
> at Parser.nextToken (/Users/frantic/code/AwesomeProject/node_modules/babylon/index.js:4877:19)
> at Parser.parse (/Users/frantic/code/AwesomeProject/node_modules/babylon/index.js:1348:10)
> at Object.parse (/Users/frantic/code/AwesomeProject/node_modules/babylon/index.js:45:50)
> at File.parse (/Users/frantic/code/AwesomeProject/node_modules/babel-core/lib/transformation/file/index.js:479:24)
> at File.parseCode (/Users/frantic/code/AwesomeProject/node_modules/babel-core/lib/transformation/file/index.js:568:20)
Issue Analytics
- State:
- Created 7 years ago
- Reactions:7
- Comments:18 (11 by maintainers)
Top Results From Across the Web
How to import image (.svg, .png ) in a React Component
try using import mainLogo from'./logoWhite.png'; //then in the render function of Jsx insert the mainLogo variable class NavBar extends ...
Read more >Asset Management - webpack
Let's try it out by adding a new style.css file to our project and import it in our index.js : project webpack-demo |-...
Read more >Using images - Canvas API - MDN Web Docs
External images can be used in any format supported by the browser, such as PNG, GIF, or JPEG. You can even use the...
Read more >Static Asset Handling - Vite
js import imgUrl from './img.png' document.getElementById('hero-img').src = imgUrl ... Common image, media, and font filetypes are detected as assets ...
Read more >Blog - Next.js 13
Next.js 13 introduces layouts, React Server Components, and streaming in the app directory, as well as Turbopack, an improved image ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This was fixed last week 😃 https://github.com/facebook/metro-bundler/commit/679309987b3572860e2f8fa7e08f9a315718d0ca
This is not fixed yet and should remain open. @hramos