Giter Site home page Giter Site logo

postcss-use's Introduction

postcss-use Build Status

Enable PostCSS plugins directly in your stylesheet.

Install

With npm do:

npm install postcss-use --save

Example

Both hash maps and arrays are supported; note that functions are not, for security reasons. A hash map uses the CSS format of option: value; option2: value2, but please note that values must be valid JSON syntax. For example if a module takes a string option, it must be wrapped in quotation marks.

Input

Standard syntax

With postcss-discard-comments:

@use postcss-discard-comments(removeAll: true);
/*! test */
h1 {
    color: red
}

Alternative syntax

You may also use configuration blocks that are more CSS-like. Note that array options cannot be parsed by this method.

@use postcss-discard-comments {
    removeAll: true
}

Output

h1 {
    color: red
}

API

use(options)

options

modules

Type: array|string Required option.

You must specify this array of postcss plugins to use, for security purposes. This prevents malicious usage of postcss-use in browser environments.

postcss([ use({ modules: ['autoprefixer', 'cssnano', 'cssnext']}) ]);

Note that you may also set this option to '*' to disable whitelisting of modules. This is not recommended for environments where you may be accepting arbitrary user input; use at your own risk.

resolveFromFile

Type: boolean (default: false)

Set this to true in order to resolve plugins relative to the file that referenced them. This enables the usage of different versions of the same plugin, for instance.

postcss([ use({ resolveFromFile: true, modules: '*' }) ]);
options

Type: object (default: {})

Default options for plugins, keyed by plugin name. If both the default and the specified options are objects, they are merged. Otherwise, the options specified in the CSS are used.

postcss([
    use({
        modules: '*',
        options: {
            autoprefixer: {
                browsers: ['> 1%', 'IE 7']
            }
        }
    })
]);

Usage

See the PostCSS documentation for examples for your environment.

Contributors

Thanks goes to these wonderful people (emoji key):


Ben Briggs

πŸ’» πŸ“– πŸ‘€ ⚠️

Jonathan Neal

πŸ’» ⚠️

一丝

πŸ’»

Maxime Thirouin

πŸ“–

Bogdan Chadkin

πŸ“– πŸ‘€

Espen Hovlandsdal

πŸ’» ⚠️

Andrey Sitnik

πŸ‘€

This project follows the all-contributors specification. Contributions of any kind welcome!

License

MIT Β© Ben Briggs

postcss-use's People

Contributors

ben-eb avatar greenkeeperio-bot avatar jonathantneal avatar moox avatar rexxars avatar trysound avatar yisibl avatar

Watchers

 avatar  avatar

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.