create-react-app icon indicating copy to clipboard operation
create-react-app copied to clipboard

cannot refer url file in public folder using '/'

Open tanatach opened this issue 4 years ago • 4 comments

Cannot resolve file path in public folder such that

background-image: url(/images/icon.svg);

The icon.svg is in public/images the error display as below

Error: Can't resolve 'src/images/icon.svg'

tanatach avatar Jul 11 '21 14:07 tanatach

Cannot resolve file path in public folder such that

background-image: url(/images/icon.svg);

The icon.svg is in public/images the error display as below

Error: Can't resolve 'src/images/icon.svg'

I think you can try moving icon.svg to src/images/

paqstd-dev avatar Jul 12 '21 16:07 paqstd-dev

put the icon.svg file into public/images folder and refer to it via <img src="images/icon.svg"/> or background: url("images/icon.svg") I didn't see quotes in your url example above.

dagolinuxoid avatar Aug 05 '21 08:08 dagolinuxoid

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

stale[bot] avatar Jan 09 '22 15:01 stale[bot]

I'm facing similar issue. I have one jpg image in my project, which is located at '/public/images/sample.jpg'. After running npm start, it appeared at 'http://127.0.0.1:3000/static/media/sample.21161eecaa099ee42c7a.jpg'. Currently there's no way I can reference this image in my tsx file.

wsy avatar Oct 01 '24 17:10 wsy