HarveyD / react-component-library

A project skeleton to get your very own React Component Library up and running using Rollup, Typescript, SASS + Storybook
https://blog.harveydelaney.com/creating-your-own-react-component-library/
MIT License
790 stars 167 forks source link

Issue with background images in scss files #5

Closed MagneH closed 4 years ago

MagneH commented 4 years ago

In conjunction to the previous issue I mentioned, I also struggled to resolve background images specified in a component scss file.

The path is injected, but the image does not seem to be added to the component bundle. It works in storybook, probably because this is handled by webpack, but when I test my library in a web-app, the images are not included.

One solution could be some sort of loader replacing all image assets referenced in scss files with the hashed version, but I have not come up with a good solution to get this working.

HarveyD commented 4 years ago

Hey, sorry about the delay.

I've done a bit of research and have found that this plugin: @rollup/plugin-image should help you resolve this issue.

HarveyD commented 4 years ago

This plugin looks like it could do the trick: https://github.com/postcss/postcss-url