sqip.macro
v0.1.0
Published
Cretes sqip at build time, similar to webpack sqip-loader
Downloads
3
Maintainers
Readme
sqip.macro
Webpack
sqip-loader
implemented 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