Skip to content

Latest commit

 

History

History
60 lines (38 loc) · 1.1 KB

README.md

File metadata and controls

60 lines (38 loc) · 1.1 KB

babel-plugin-em-media-query

Build Status

Babel plugin for transforming min/max-width/height media queries to ems.

Install

npm install babel-plugin-em-media-query --save

Usage

Use it via available plugin activation options.

For .babelrc file:

{
	"plugins": [
		"babel-plugin-em-media-query"
	]
}

Then, in your code:

/* Before */

// Standard matchMedia call
window.matchMedia('screen and (min-width:600px) and (max-width:739px)');

// Special leading comment before string or template literal
const jackie = /* @media */ 'screen and (min-width:600px)';

/* After */

window.matchMedia('screen and (min-width:37.5em) and (max-width:46.1875em)');

const jackie = 'screen and (min-width:37.5em)';

Options

precision

Type: Integer
Default: 5

Rounding precision for values.

License

MIT © Ivan Nikolić