0.1.0 • Published 6 years ago

sqip.macro v0.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

sqip.macro

Build Status Babel Macro

Webpack sqip-loader implemented as babel-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