# @moxy/postcss-preset

> PostCSS preset to be used at MOXY

Latest version **5.0.0** (published 2021-08-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install @moxy/postcss-preset
pnpm add @moxy/postcss-preset
yarn add @moxy/postcss-preset
bun add @moxy/postcss-preset
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.0.0 |
| Published | 2021-08-03 |
| First published | 2019-11-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 9.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | André Cruz |
| Maintainers | hugomrdias, moxyhq, filipediasf, satazor, marcooliveira, vascosantos, ruipneves, acostalima, threequartersjohn, raising, jdiogopeixoto, jgradim, afonsoreis05, carsy, andregoncalvesdev |
| Keywords | postcss, preset, react, moxy, transpile |

## Links

- npm: https://www.npmjs.com/package/@moxy/postcss-preset
- Repository: https://github.com/moxystudio/postcss-preset
- Issues: https://github.com/moxystudio/postcss-preset/issues
- npm.io page: https://npm.io/package/@moxy/postcss-preset

## Dependencies (7)

- [postcss-url](https://npm.io/package/postcss-url.md) ^8.0.0
- [postcss-calc](https://npm.io/package/postcss-calc.md) ^7.0.2
- [postcss-import](https://npm.io/package/postcss-import.md) ^12.0.0
- [postcss-mixins](https://npm.io/package/postcss-mixins.md) ^6.2.0
- [postcss-preset-env](https://npm.io/package/postcss-preset-env.md) ^6.7.0
- [browserslist-config-google](https://npm.io/package/browserslist-config-google.md) ^3.0.1
- [postcss-advanced-variables](https://npm.io/package/postcss-advanced-variables.md) ^3.0.1

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 5.0.0 (latest) — 2021-08-03
- 4.6.0 — 2021-06-10
- 4.5.3 — 2021-06-05
- 4.5.2 — 2021-02-04
- 4.5.1 — 2020-07-31
- 4.5.0 — 2020-07-31
- 4.4.2 — 2020-03-10
- 4.4.1 — 2020-01-17
- 4.4.0 — 2019-12-13
- 4.3.0 — 2019-11-23

## README

# postcss-preset

[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][build-status-image]][build-status-url] [![Coverage Status][codecov-image]][codecov-url] [![Dependency status][david-dm-image]][david-dm-url] [![Dev Dependency status][david-dm-dev-image]][david-dm-dev-url]

[npm-url]:https://npmjs.org/package/@moxy/postcss-preset
[npm-image]:https://img.shields.io/npm/v/@moxy/postcss-preset.svg
[downloads-image]:https://img.shields.io/npm/dm/@moxy/postcss-preset.svg
[build-status-url]:https://github.com/moxystudio/postcss-preset/actions
[build-status-image]:https://img.shields.io/github/workflow/status/moxystudio/postcss-preset/Node%20CI/master
[codecov-url]:https://codecov.io/gh/moxystudio/postcss-preset
[codecov-image]:https://img.shields.io/codecov/c/github/moxystudio/postcss-preset/master.svg
[david-dm-url]:https://david-dm.org/moxystudio/postcss-preset
[david-dm-image]:https://img.shields.io/david/moxystudio/postcss-preset.svg
[david-dm-dev-url]:https://david-dm.org/moxystudio/postcss-preset?type=dev
[david-dm-dev-image]:https://img.shields.io/david/dev/moxystudio/postcss-preset.svg

[PostCSS](http://cssnext.io/) preset to be used at MOXY.


## Installation

```ssh
$ npm install @moxy/postcss-preset --save-dev
```

You might need to also install [postcss-cli](https://github.com/postcss/postcss-cli) as a dev dependency.


## Motivation

If you are developing a project that uses new CSS language features and must work on targets that do not yet support them, you have to transpile your styles. This preset provides a shareable PostCSS config as a preset that should be used across those projects at MOXY.

- Uses [postcss-preset-env](https://www.npmjs.com/package/postcss-preset-env) to automatically support official CSS features in older browsers
  - Stage 3
  - Custom @media queries
  - Nesting rules
  - `:dir` pseudo-class (useful for i18n)
- Enables [postcss-import](https://github.com/postcss/postcss-import) so that `@import` statements are inlined
- Optionally enables [postcss-url](https://github.com/postcss/postcss-url) so that `url()` statements are processed
- Enables [postcss-mixins](https://github.com/postcss/postcss-mixins) so that you can define mixins
- Enables [postcss-advanced-variables](https://github.com/jonathantneal/postcss-advanced-variables) add support for iterators (@for and @each) and conditionals (@if and @else)
- Enables [postcss-calc](https://github.com/postcss/postcss-calc) so that `calc()` references are reduced whenever it's possible


## Usage

Create `postcss.config.js` at the root of your project:

```js
module.exports = require('@moxy/postcss-preset')();
```

...or with options

```js
module.exports = require('@moxy/postcss-preset')({
    import: { path: './src/styles' },
    mixins: { mixinsDir: './src/styles/mixins' },
    advancedVariables: { unresolved: 'warn' },
});
```

Available options:

| Name   | Description   | Type     | Default |
| ------ | ------------- | -------- | ------- |
| import | Options to pass to [postcss-import](https://github.com/postcss/postcss-import#path) | Object | `{}` |
| mixins | Options to pass to [postcss-mixins](https://github.com/postcss/postcss-mixins#mixinsdir) | Object | `{ mixinsDir: './src/styles/mixins' }` |
| advancedVariables | Options to pass to [postcss-advanced-variables](https://github.com/jonathantneal/postcss-advanced-variables#options) | Object | `{}`¹ |
| url | Options to pass to [postcss-url](https://github.com/postcss/postcss-url), false disables any transpilation of `url()` declarations | Array/Object/boolean | `{ url: 'rebase' }` |
| browsers | Supported browsers list to pass to [postcss-cssnext](https://github.com/MoOx/postcss-cssnext) | Array | `['extends browserslist-config-google/modern']`, see [browserslist-config-google](https://github.com/awkaiser/browserslist-config-google) (modern)  |

1) `advancedVariables` is not actually empty by default since it contains `{disable: '@mixin, @include, @content, @import'}` but this options can be easily changed by passing the desired `disable` object.

The [postcss-url](https://github.com/postcss/postcss-url) plugin is enabled by default. You may disable it like so:

```js
module.exports = require('@moxy/postcss-preset')({
    url: false,
});
```


## Tests

```sh
$ npm test
$ npm test -- --watch # during development
```


## License

[MIT License](http://opensource.org/licenses/MIT)

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