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

Image assets #8

Open
oliverjam opened this issue Feb 1, 2019 · 0 comments
Open

Image assets #8

oliverjam opened this issue Feb 1, 2019 · 0 comments

Comments

@oliverjam
Copy link

oliverjam commented Feb 1, 2019

background-image: url("https://www.dropbox.com/s/2lo7p1rykwt840y/GEMSM.png?raw=1");

I'm not 100% sure what's happening here, but it looks like you might have been struggling to get the image src in your project.

Parcel allows you to import assets like images into your JS files to automatically include them in the dist/ folder. E.g.

import gemImage from './GEMbig.png`; // "dist/GEMbig-123ibgdsk.png"

function Gem() {
  return <img src={gemImage} />;
}

I'm not sure there's a good way to get access to them within a CSS file unfortunately, so if you need a background image you'd probably have to set that inline. Something like:

import gemImage from './GEMbig.png`; // "dist/GEMbig-lkadf29.png"

function UserImage(props) {
  return (
    <div style={{ backgroundImage: gemImage }}>
      <img src={props.avatar_url} />
    </div>
  )
}
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