Giter VIP home page Giter VIP logo

postcss-cli's Introduction

Build Status Dependency Status NPM version

postcss-cli

Traditional CLI for postcss

Installation

npm install postcss-cli

postcss-cli version postcss version
1.x 4.x
2.x 5.x

Usage

postcss [options] [-o output-file|-d output-directory|-r] [input-file]

--output|-o

Output file name. If no output file is specified, postcss will write to stdout, however plugins that rely on output file location will not work properly.

Similarly, if no input file is specified, postcss will read from stdin. Plugins that rely on input file location will not work properly.

--dir|-d

Output files location. Either --output, --dir or --replace option, but not all of them, need to be specified. --dir or --replace needs to be used if multiple input file is provided.

--replace|-r

Replace input file(s) with generated output. Either --output, --dir or --replace option, but not all of them, need to be specified. --replace or --dir needs to be used if multiple input file is provided.

--use|-u

Plugin to be used. Multiple plugins can be specified. At least one is required unless specified within config file.

--watch|-w

Observe file system changes and recompile as source files change.

When inlining CSS imports (e.g. with postcss-import), add an update handler to your JavaScript configuration file to ensure referenced modules are taken into account:

{
  "postcss-import": {
    onImport: function(sources) {
      global.watchCSS(sources);
    }
  }
}

--config|-c

JSON file with plugin configuration. Plugin names should be the keys.

{
    "autoprefixer": {
        "browsers": "> 5%"
    },
    "postcss-cachify": {
        "baseUrl": "/res"
    }
}

JavaScript configuration can be used if functions are allowed as plugins parameters:

module.exports = {
  "postcss-url": {
    url: function(url) { return "http://example.com/" + url; }
  },
  autoprefixer: {
    browsers: "> 5%"
  }
};

Alternatively configuration options can be passed as --plugin.option parameters.

Note that command-line options can also be specified in the config file:

{
    "use": ["autoprefixer", "postcss-cachify"],
    "input": "screen.css",
    "output": "bundle.css",
    "autoprefixer": {
        "browsers": "> 5%"
    },
    "postcss-cachify": {
        "baseUrl": "/res"
    }
}

-s, --syntax

Optional module to use as a custom PostCSS syntax.

-p, --parser

Optional module to use as a custom PostCSS input parser.

-t, --stringifier

Optional module to use as a custom PostCSS output stringifier.

-h, --help

Show help

Examples

Use autoprefixer as a postcss plugin pass parameters from a json file

postcss --use autoprefixer -c options.json -o screen.css screen.css

Use more than one plugin and pass config parameters

postcss --use autoprefixer --autoprefixer.browsers "> 5%" \
    --use postcss-cachify --postcss-cachify.baseUrl /res \
    -o screen.css screen.css

Use multiple plugins and multiple input files

postcss -u postcss-cachify -u autoprefixer -d build *.css

Licence

MIT

postcss-cli's People

Contributors

pirxpilot avatar fnd avatar mkurz avatar ai avatar sciyoshi avatar vtrrsl avatar

Watchers

James Cloos avatar Ping Chen 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.