sqip.macro
May 20, 2018 ยท View on GitHub
Webpack
sqip-loaderimplemented asbabel-plugin-macros
Usage
Similar to nodejs require call:
import sqip from "sqip.macro";
const preview = sqip("./image.jpg");
Example of usage in create-react-app
import coverImage from "./cover-image.jpg";
import sqip from "sqip.macro";
const coversqip = sqip("./cover-image.jpg");
const SomeComponent = () => (
<div
style={{
backgroundImage: `url(${coversqip}`,
backgroundSize: "cover",
backgroundRepeat: "no-repeat",
}}
>
<img src={coverImage} alt="" width="100%" height="100%" />
</div>
);
Credits
Based on pveyes/raw.macro.
License
MIT