• Stars
    star
    175
  • Rank 218,059 (Top 5 %)
  • Language
    JavaScript
  • Created over 9 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple CLI for postcss

NPM version Build Status Dependency Status

postcss-cli-simple

Simple CLI for postcss. To be used in Makefiles. If you are looking for more options check out postcss-cli. More on the history of this project.

Installation

npm install postcss-cli-simple

Usage

postcss [options] -o output-file input-file

In Makefile you can use it with pattern rules:

deploy/%.css: %.css
  ./node_modules/.bin/postcss \
    --use postcss-url --postcss-url.url=rebase \
    --use autoprefixer --autoprefixer.browsers "> 5%" \
    --use cssnano --no-cssnano.discardUnused
    --output $@ $<

--output|-o

Output file name.

--use|-u

Plugin to be used. Multiple plugins can be specified. At least one plugin needs to be specified either with --use option or in the config file.

Plugin options can be specified using yargs dot notation. For example, to pass browsers option to autoprefixer one can use --autoprefixer.browsers "> 5%". To set plugin option to false use yargs boolean negation. For example, to switch off discardUnused in cssnano try: --no-cssnano.discardUnused.

--map|-m

Activate source map generation. By default inline maps are generated. To generate source maps in a separate .map file use --map file or --no-map.inline.

You can use advances source map options - some examples:

  • --no-map - do not generated source maps - even if previous maps exist
  • --map.annotation <path> - specify alternaive path to be used in source map annotation appended to CSS
  • --no-map.annotation - supress adding annotation to CSS
  • --no-map.sourcesContent - remove origin CSS from maps

--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. Although you might be better off writing your own plugin.

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"],
    "output": "bundle.css",
    "autoprefixer": {
        "browsers": "> 5%"
    },
    "postcss-cachify": {
        "baseUrl": "/res"
    }
}

--syntax|-s

Optional module to use as a custom PostCSS syntax.

--parser|-p

Optional module to use as a custom PostCSS input parser.

--stringifier|-t

Optional module to use as a custom PostCSS output stringifier.

--help|-h

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

License

MIT

More Repositories

1

liftie

🎿 Clean, simple, easy to read, fast ski resort lift status.
HTML
55
star
2

connect-gzip-static

connect middleware for statically compressed files
JavaScript
41
star
3

dataset

Shim for DOM dataset
JavaScript
16
star
4

grunt-mincer

grunt plugin for mincer
JavaScript
14
star
5

stylus-font-face

bulletproof @font-face in stylus
CSS
14
star
6

ga

Google Analytics tracking snippet
JavaScript
7
star
7

component-autoboot

Plugin for component build: appends require('boot') to the output script
JavaScript
7
star
8

postal-async

Async NAPI based interface for libpostal
C++
7
star
9

jsonp

Tiny subset of superagent-like API to be used with jsonp requests
HTML
5
star
10

kompas

Calculates heading based on "deviceorientation" event.
JavaScript
5
star
11

component-shrinkwrap

Shrinkwrap for component build system.
JavaScript
4
star
12

popup-clock

a timepicker component
HTML
4
star
13

plumper

Makes your polyline look fat
JavaScript
4
star
14

vis-why

M Visvalingam and J D Whyatt line simplification algorithm
JavaScript
4
star
15

tweet-html

reparse tweets returned by twitter API to HTML
JavaScript
4
star
16

postcss-cachify

PostCSS plugin to replace assets urls with cachified versions.
JavaScript
4
star
17

connect-cachify-static

static (simpler and faster) variant of connect-cachify middleware
JavaScript
4
star
18

clock

Clock UI component for use in time-picker
JavaScript
3
star
19

postal-api

REST API server for libpostal
Shell
3
star
20

parse-zoneinfo

Async parser for binary tzdata zoneinfo files.
JavaScript
2
star
21

poly2geojson

Convert Osmosis polygon filter file to GeoJSON polygon.
JavaScript
2
star
22

twitter-timeline

Twitter timeline similar to twitter widget.
JavaScript
2
star
23

ga-event

Google Analytics component with event tracking
JavaScript
2
star
24

getlet

HTTP(s) get request with redirect, compress and streaming
JavaScript
2
star
25

google-ua

Google Universal Analytics snippet
JavaScript
2
star
26

addthis

Load addthis.com snippet asynchronously.
Makefile
2
star
27

scroll-hilo

Adds CSS classes based on scroll position
HTML
2
star
28

tile-cache

Client side slippy tile cache
JavaScript
1
star
29

close-enough

fuzzy string compare
JavaScript
1
star
30

scrollbar-diet

Makes scrollbars thin and orange
CSS
1
star
31

poziomka

Fast and opinionated leveldb interface
C++
1
star
32

cse

Google custom search engine on your page
JavaScript
1
star
33

el

creates HTML from jade like expressions
JavaScript
1
star
34

dump-tile

Dumps MVT tiles encoded in .pbf to JSON
JavaScript
1
star
35

zaraz

Cheap way to introduce short async delay. ⌚
JavaScript
1
star
36

rating

Displays stars based on numeric rating (read-only).
JavaScript
1
star
37

hoot

Inter-worker message-based communication in the node cluster.
JavaScript
1
star
38

limiter

Limits the rate of function calls to one per period.
JavaScript
1
star
39

esbuild-plugin-drop

JavaScript
1
star