Miss any of our Open RFC calls?Watch the recordings here! »

image-size.macro

0.1.0 • Public • Published

image-size.macro 📐

Image size at build time using babel-plugin-macros

Integration Status Babel Macro License

image-size.macro is a Babel macro that gives you the size of an image (width & height) at build time using babel-plugin-macros and image-size.

Usage

Installation

  1. Install babel-plugin-macros and the macro:
yarn add -D babel-plugin-macros image-size.macro

or

npm install --save-dev babel-plugin-macros image-size.macro
  1. Add the plugin to your Babel configuration:

.babelrc

{
  "plugins": [
    "other-plugins",
+   "macros",
  ]
}

babel.config.js

module.exports = {
  plugins: [
    ...otherPlugins,
+   'macros',
  ]
}

Example

import imageSize from 'image-size.macro'
 
const myImageSize = imageSize('./my-image.png')

↓ ↓ ↓ ↓ ↓ ↓

const myImageSize = { height: 20, width: 10 }

License

Licensed under the MIT License, Copyright © HiDeoo.

See LICENSE for more information.

Install

npm i image-size.macro

DownloadsWeekly Downloads

3

Version

0.1.0

License

MIT

Unpacked Size

35 kB

Total Files

19

Last publish

Collaborators

  • avatar