GithubHelp home page GithubHelp logo

necolas / cssnext Goto Github PK

View Code? Open in Web Editor NEW

This project forked from moox/postcss-cssnext

5.0 4.0 1.0 120 KB

Use tomorrow's CSS syntax, today

Home Page: http://cssnext.github.io/

License: MIT License

cssnext's Introduction

cssnext

Build Status Code Climate NPM version

Use tomorrow's CSS syntax, today.

This is not a CSS preprocessor, but can replace one.
This is a CSS transpiler (CSS4+ to CSS3) that allow you to use tomorrow's CSS syntax today. It transforms CSS specs that are not already implemented in popular browsers into more compatible CSS.
Take a look to available features.

cssnext is similar to Myth or SUIT CSS preprocessor but push the concept to the next level by supporting more features.

cssnext works great with SUIT CSS and cssrecipes.

tl;dr : try cssnext in your browser.

Follow @cssnext to get latest news & join #cssnext on irc.freenode.net if you have any questions.

Goals

  • Allow using future CSS syntax today.
  • Keep code close as possible to the original code.

Non-Goals

  • Provide polyfills for future CSS APIs that depend on the client browser.

Features

Available

Additionals enhancements

  • @import inline local files (via postcss-import) to output an bundled CSS file.

@todo

Any omissions of the CSS specifications (even in draft) that are subject to be handled by cssnext are not intentional.
Feel free to open a new issue if you find something that should be handled.
Keep in mind that, as of right now, this project is intended to support new CSS syntax only.


Installation

$ npm install cssnext

You can install it

  • globally (-g), to use it through the CLI
  • locally ()--save or --save-dev), to use it through npm scripts (npm run) or via .node_modules/.bin/csnext
  • by using other tools like gulp-cssnext

Usage

You can use cssnext using CLI, as a JavaScript library or through others tools.

CLI

cssnext offer a command-line interface. Here's how to compile a file and print it to stdout:

$ cssnext index.css

To create an output file, you can just add a second argument

$ cssnext index.css output.css

Or use CLI std(in|out) redirection(s)

$ cat input.css | cssnext > output.css

CLI options

If you don't care about a certain feature, such as custom media queries, you can omit support for them like so:

$ cssnext --no-custom-media index.css

To enable source maps for these files, add the --sourcemap flag.

To see all CLI options

$ cssnext --help

Node.js API

var cssnext = require("cssnext")
var fs = require("fs")

var input = fs.readFileSync("index.css", "utf8")

var output = cssnext(input)
fs.writeFileSync("dist/index.css", output)

cssnext accept 2 arguments: a css string and an object of options.

Node.js options

For now, all options are passed to all postcss plugins. This mean you should be able to any specific plugin options.

features (default: all features)

Object containing key of features to enable/disable.
No key means feature is enabled.

//eg: disable color support
var output = cssnext({
  features: {
    color: false
  }
})

Here is all available features:

  • import
  • customProperties
  • calc
  • customMedia
  • color
  • prefixes
browsers (default: autoprefixer default)

Array to specify browsers you want to target (for now only used by autoprefixer).
See autoprefixer documentation of this option for more details.

Default to something like ["> 1%", "last 2 versions", "Firefox ESR"].

compress (default: false)

Allow you to compress the output (using CSSWring).

sourcemap (default: false)

If you want a accurate sourcemap, please use instead the from option.

This option is a shortcut to enable inlined sourcemap in the output.
Just pass true to get the sourcemap at the end of the output.
If you want better control on sourcemap, use postcss map option directly.

from (default: null)

Source of the file. Needed for sourcemap.

var cssnext = require("cssnext")
var fs = require("fs")

var source = "./index.css"
var output = cssnext(
  fs.readFileSync(source, "utf8"),
  {from: source}
)
fs.writeFileSync("dist/index.css", output)
path (default: dirname(from) || process.cwd())

A string or an array of paths in where to look for files when inlining using @import.
Default to dirname of postcss from or fallback to process.cwd().

Note: nested @import will additionally benefit of the relative dirname of imported files.

Usage with other tools

Here are some tools that will help you use cssnext in your current workflow


Contributing

cssnext uses a lot of postcss plugins, so you might need to take a look at them if you found an issue or want to create or enhance a feature.

Otherwise, work on a branch, install dev-dependencies, respect coding style & run tests before submitting a bug fix or a feature.

$ git clone https://github.com/cssnext/cssnext.git
$ git checkout -b patch-1
$ npm install
$ npm test

Acknowledgements

Huge thanks to all the people that where involved in :

Thanks to Andrey Sitnik for postcss.

Without all those people, this project would not exist.

cssnext's People

Contributors

bloodyowl avatar colons avatar marcgg avatar moox avatar tauren avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

thesobek

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.