Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

precss

jonathantneal244.3kCC0-1.0deprecated4.0.0

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

Use Sass-like markup and staged CSS features in CSS

postcss, css, postcss-plugin, sass, scss, variables, conditionals, iterations, iterators, iterables, iterate, contents, eaches, elses, fors, ifs, includes, imports, medias, queries, query, mixins, defaults, functions, colors, customs, dirs, system-ui, image-set, logical, properties, blocks, inlines, starts, ends, any-link, font-variant, overflow-wrap, system-ui, caniuse

readme

PreCSS PostCSS Logo

NPM Version Build Status Support Chat

PreCSS lets you use Sass-like markup and staged CSS features in CSS.

$blue: #056ef0;
$column: 200px;

.menu {
  width: calc(4 * $column);
}

.menu_link {
  background: $blue;
  width: $column;
}

/* becomes */

.menu {
  width: calc(4 * 200px);
}

.menu_link {
  background: #056ef0;
  width: 200px;
}

PreCSS combines Sass-like syntactical sugar — like variables, conditionals, and iterators — with emerging CSS features — like logical and custom properties, media query ranges, and image sets.

Usage

Add PreCSS to your build tool:

npm install precss --save-dev

Node

Use PreCSS to process your CSS:

import precss from 'precss';

precss.process(YOUR_CSS);

PostCSS

Add PostCSS to your build tool:

npm install postcss --save-dev

Use PreCSS as a plugin:

import postcss from 'postcss';
import precss from 'precss';

postcss([
  precss(/* options */)
]).process(YOUR_CSS);

Gulp

Add Gulp PostCSS to your build tool:

npm install gulp-postcss --save-dev

Use PreCSS in your Gulpfile:

import postcss from 'gulp-postcss';
import precss from 'precss';

gulp.task('css', function () {
  return gulp.src('./src/*.css').pipe(
    postcss([
      precss(/* options */)
    ])
  ).pipe(
    gulp.dest('.')
  );
});

Grunt

Add Grunt PostCSS to your build tool:

npm install grunt-postcss --save-dev

Use PreCSS in your Gruntfile:

import precss from 'precss';

grunt.loadNpmTasks('grunt-postcss');

grunt.initConfig({
  postcss: {
    options: {
      use: [
        precss(/* options */)
      ]
    },
    dist: {
      src: '*.css'
    }
  }
});

Plugins

PreCSS is powered by the following plugins (in this order):

changelog

Changes to PreCSS

4.0.0 (November 23, 2018)

  • Updated: postcss to 7.0.6 (major)
  • Updated: postcss-advanced-variables to 3.0.0 (major)
  • Updated: postcss-extend-rule to 2.0.0 (major)
  • Updated: postcss-nested to 4.1.0 (major)
  • Updated: postcss-preset-env to 6.4.0 (major)

3.1.2 (February 27, 2018)

  • Updated: postcss-advanced-variables to 2.3.3 (patch)
  • Updated: postcss-preset-env to 3.2.2 (patch)

3.1.1 (February 21, 2018)

  • Updated: Dependencies to latest working release (no major bumps)

3.1.0 (Janaury 22, 2018)

  • Updated: PostCSS Preset Env 2.1 (major)

3.0.0 (Janaury 16, 2018)

  • Changed: Using PostCSS Advanced Variables instead of the following;
    • PostCSS Import
    • PostCSS Mixins
  • Changed: Using PostCSS Preset Env instead of the following;
    • PostCSS Color Function
    • PostCSS Custom Media
    • PostCSS Custom Properties
    • PostCSS Custom Selectors
    • PostCSS Media MinMax
    • PostCSS Nesting
    • PostCSS Selector Matches
    • PostCSS Selector Not
  • Changed: Using PostCSS Extend Rule instead of PostCSS Extend
  • Updated: PostCSS Advanced Variables 2.3 (major)
  • Updated: PostCSS Property Lookup 2.0 (major)
  • Updated: PostCSS Nested 3.0 (major)

2.0.0 (January 6, 2018)

  • Updated: PostCSS 6 (major)
  • Updated: Plugin organization

1.4.0 (October 24, 2015)

  • Added: PostCSS At-Root 0.1.2
  • Added: PostCSS Property Lookup 1.1.3
  • Updated: Tests and documentation

1.3.0 (October 21, 2015)

  • Updated: PostCSS 5.0.10 (patch)
  • Updated: PostCSS Advanced Variables 1.2.2 (minor)
  • Updated: PostCSS Extend 1.0.1 (minor)
  • Updated: PostCSS Mixins 2.1.0 (major)
  • Updated: PostCSS Nesting 2.0.6 (patch)
  • Updated: Tests and documentation

1.2.3 (September 24, 2015)

  • Updated: Move selectors after nesting

1.2.2 (September 24, 2015)

  • Updated: package.json to spaces

1.2.1 (September 24, 2015)

  • Updated: Plugin ordering

1.2.0 (September 24, 2015)

  • Added: PostCSS Nesting 2.0.4
  • Added: Tests for @nest
  • Updated: PostCSS 5.0.6
  • Updated: PostCSS Mixins 1.0.1
  • Deprecated: PostCSS Nesting 2.0.4

1.1.3 (September 14, 2015)

  • Updated: PostCSS 5.0.5
  • Updated: PostCSS Partial Import 1.3.0

1.1.2 (September 08, 2015)

  • Updated: PostCSS Partial Import 1.1.1

1.1.1 (September 08, 2015)

  • Updated: PostCSS Extend 1.1.0

1.1.0 (September 08, 2015)

  • Added: PostCSS Extend
  • Added: PostCSS Partial Import
  • Added: PostCSS W3C Custom Media
  • Added: PostCSS W3C Custom Properties
  • Added: PostCSS W3C Custom Selectors
  • Added: PostCSS W3C Multiple Matches
  • Added: PostCSS W3C Multiple Nots
  • Updated: PostCSS Media Minmax 2.1.0
  • Updated: Documentation
  • Removed: PostCSS Import
  • Removed: PostCSS Sass Extend

1.0.0 (September 07, 2015)

  • Updated: PostCSS 5.0.4
  • Updated: PostCSS Advanced Variables 1.0.0
  • Updated: PostCSS Color Function 2.0.0
  • Updated: PostCSS Import 7.0.0
  • Updated: PostCSS Media Minmax 2.0.0
  • Updated: PostCSS Mixins 1.0.0
  • Updated: PostCSS Nested 1.0.0
  • Updated: PostCSS Simple Extend 1.0.0
  • Updated: ESLint 1.0.0
  • Removed: PostCSS Simple Vars
  • Removed: PostCSS process method which is now in core

0.3.0 (July 22, 2015)

  • Added: postcss-advanced-variables support for vars in @media
  • Added: postcss-import skipDuplicates option to allows you to not skip duplicated files
  • Added: postcss-mixins mixinsFiles option.
  • Updated: other plugins without notable changes

0.2.2 (July 10, 2015)

  • Updated: Documentation

0.2.1 (July 10, 2015)

  • Added: Switch from postcss-sass-extend to postcss-simple-extend

0.1.3 (July 08, 2015)

  • Added: Support for @else statements
  • Updated: Dependencies

0.1.2 (July 08, 2015)

  • Updated: Tests to support nested options

0.1.1 (July 08, 2015)

  • Fixed: Re-ordered plugins so they don’t break each other
  • Changed: Plugin option namespaces
  • Removed: Unnecessary default options

0.1.0 (July 08, 2015)

  • Changed: Named project precss

0.0.2 (July 07, 2015)

  • Updated: Swapped conditional, for, and each for advanced-variables

0.0.1 (July 06, 2015)

Pre-release