0.1.0 • Published 4 years ago
image-size.macro v0.1.0
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
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.
0.1.0
4 years ago