image-size.macro 📐
Image size at build time using babel-plugin-macros
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
- 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
- Add the plugin to your Babel configuration:
.babelrc
{ "plugins": [ "other-plugins",+ "macros", ]}
babel.config.js
module.exports = { plugins: [ ...otherPlugins,+ 'macros', ]}
Example
const myImageSize =
↓ ↓ ↓ ↓ ↓ ↓
const myImageSize = height: 20 width: 10
License
Licensed under the MIT License, Copyright © HiDeoo.
See LICENSE for more information.