# postcss-preserve-px-fontsize

> preserve px font-size from postcss-px-to-viewport

Latest version **0.1.1** (published 2018-11-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install postcss-preserve-px-fontsize
pnpm add postcss-preserve-px-fontsize
yarn add postcss-preserve-px-fontsize
bun add postcss-preserve-px-fontsize
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2018-11-11 |
| First published | 2018-11-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | ta7sudan |
| Maintainers | ta7sudan |
| Keywords | postcss, fontsize, px, vw, preserve |

## Links

- npm: https://www.npmjs.com/package/postcss-preserve-px-fontsize
- Repository: https://github.com/ta7sudan/postcss-preserve-px-fontsize
- Homepage: https://github.com/ta7sudan/postcss-preserve-px-fontsize#readme
- Issues: https://github.com/ta7sudan/postcss-preserve-px-fontsize/issues
- npm.io page: https://npm.io/package/postcss-preserve-px-fontsize

## Recent versions

- 0.1.1 (latest) — 2018-11-11
- 0.1.0 — 2018-11-10

## README

# postcss-preserve-px-fontsize
preserve px font-size from postcss-px-to-viewport, only for vw unit.



## Requirement

Must set this plugin after [postcss-px-to-viewport](https://github.com/evrone/postcss-px-to-viewport).



## Usage

```javascript
const postcss = require('postcss');
const preserveFontSize = require('../src/index');
const fs = require('fs');

const css = fs.readFileSync('./example/test.css', 'utf8');

postcss([preserveFontSize({
	viewportWidth: 750,
	lineHeight: true
})]).process(css).then(rst => {
	console.log(rst.css);
});
```

input

```css
div {
	font-size: 50vw;
	/* 375px */
	font: bold 4.267vw/50vw "Microsoft Yahei"; 
	/* 32px */
	color: red;
	line-height: 4.267vw;
}
```

output

```css
div {
	font-size: 375px;
	/* 375px */
	font: bold 32px/375px "Microsoft Yahei"; 
	/* 32px */
	color: red;
	line-height: 32px;
}
```



## Options

* `viewportWidth` same as [postcss-px-to-viewport](https://github.com/evrone/postcss-px-to-viewport#options)
* `lineHeight` boolean, should preserve px unit for `line-height`



## Skip a declaration

Maybe you want to use vw for a specified declaration, you can add a comment `/* skipvw */` after the declaration.

```css
div {
	font-size: 50vw; /* skipvw */
	/* 375px */
	font: bold 4.267vw/50vw "Microsoft Yahei"; 
	/* 32px */
	color: red;
	line-height: 4.267vw;
}
```

This will preserve vw for `font-size`.

output

```css
div {
	font-size: 50vw; /* skipvw */
	/* 375px */
	font: bold 32px/375px "Microsoft Yahei"; 
	/* 32px */
	color: red;
	line-height: 32px;
}
```

---
_Source: https://npm.io/package/postcss-preserve-px-fontsize · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
