GithubHelp home page GithubHelp logo

postcss-preset's Introduction

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.

  • Uses 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 so that @import statements are inlined
  • Optionally enables postcss-url so that url() statements are processed
  • Enables postcss-mixins so that you can define mixins
  • Enables postcss-advanced-variables add support for iterators (@for and @each) and conditionals (@if and @else)
  • Enables postcss-calc so that calc() references are reduced whenever it's possible

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:

Name Description Type Default
import Options to pass to postcss-import Object {}
mixins Options to pass to postcss-mixins Object { mixinsDir: './src/styles/mixins' }
advancedVariables Options to pass to postcss-advanced-variables Object {}ยน
url Options to pass to postcss-url, false disables any transpilation of url() declarations Array/Object/boolean { url: 'rebase' }
browsers Supported browsers list to pass to postcss-cssnext Array ['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

postcss-preset's People

Contributors

andrefgneves avatar dependabot[bot] avatar dominguesgm avatar greenkeeper[bot] avatar nlfonseca avatar pedromiguelss avatar ritazoliveira avatar satazor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

isabella232

postcss-preset's Issues

Add conditionals and iterators

Since https://github.com/andyjansson/postcss-conditionals was archived and we need another plugin for conditionals I suggest using https://github.com/jonathantneal/postcss-advanced-variables. With this plugin we can also have iterators ๐ŸŽ‰
If using https://github.com/jonathantneal/postcss-advanced-variables we no longer need https://github.com/postcss/postcss-mixins.

With this, we can have:

In the case of the mixins, syntax changes:

Before:

@define-mixin  heading-text {
  color: #242424;
  font-size: 4em;
}

h1 {
  @mixin heading-text;
}

After:

@mixin heading-text {
  color: #242424;
  font-size: 4em;
}

h1 {
  @include heading-text;
}

Check "Custom Properties" based on browser needs

Custom properties are currently supported by most browsers:

imagem

Although there are a few, like IE, that do not provide support by default.

We should try and only enable custom properties based on which browsers we aim to support and their needs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.