What is the correct way of using a static / assets folder with Parcel 2? #4716
Answered
by
mischnic
halvardssm
asked this question in
General
-
As the title asks. I have a large number of static files (images, logos etc.) which I would like to include and make available by referencing them directly in the react-dom. Example: render(){
return <div><img src="static/logo.png" /></div>
} Another use-case is when I want to reference the assets programmatically: export const FunctionalImageComponent = ({ src: string }) => <img src={src} />
...
render(){
return <FunctionalImageComponent src="static/logo.png" />
} Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Answered by
mischnic
Jun 8, 2020
Replies: 1 comment 7 replies
-
Parcel 1: import logo from "static/logo.png";
render(){
return <div><img src={logo} /></div>
} Parcel 2: import logo from "url:static/logo.png";
render(){
return <div><img src={logo} /></div>
} (The full path of the asset has to be statically analyzable) |
Beta Was this translation helpful? Give feedback.
7 replies
Answer selected by
halvardssm
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Parcel 1:
Parcel 2:
(The full path of the asset has to be statically analyzable)