Home

Awesome

postcss-preset

NPM version Downloads Build Status Coverage Status Dependency status Dev Dependency status

PostCSS preset to be used at MOXY.

Installation

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

You might need to also install 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.

Usage

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

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

...or with options

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

Available options:

NameDescriptionTypeDefault
importOptions to pass to postcss-importObject{}
mixinsOptions to pass to postcss-mixinsObject{ mixinsDir: './src/styles/mixins' }
advancedVariablesOptions to pass to postcss-advanced-variablesObject{}¹
urlOptions to pass to postcss-url, false disables any transpilation of url() declarationsArray/Object/boolean{ url: 'rebase' }
browsersSupported browsers list to pass to postcss-cssnextArray['extends browserslist-config-google/modern'], see 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 plugin is enabled by default. You may disable it like so:

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

Tests

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

License

MIT License