1.0.1 • Published 7 years ago

postcss-words v1.0.1

Weekly downloads
1
License
CC0-1.0
Repository
github
Last release
7 years ago

Words

NPM Version Build Status Licensing Changelog Gitter Chat

Words lets you transform CSS words into custom values in CSS.

{
    "midnight-moss": "#041004",
    "red": "#ce2029"
}
/* before */

.hero {
    box-shadow: 0 0 0 0 midnight-moss;
    background-color: red;
    color: blue;
}

/* after */

.hero {
    box-shadow: 0 0 0 0 #041004;
    background-color: #ce2029;
    color: blue;
}

Options

words

Type: Object|String
Default: .csswords.json

The file or object to reference when updating CSS words.

functions

Type: Array|String
Default: ["url"]

A list of functions to avoid parsing within.

Usage

Add Words to your build tool:

npm install postcss-words --save-dev

Node

require('postcss-words').process(YOUR_CSS, { /* options */ });

PostCSS

Add PostCSS to your build tool:

npm install postcss --save-dev

Load Words as a PostCSS plugin:

postcss([
	require('postcss-words')({ /* options */ })
]).process(YOUR_CSS, /* options */);

Gulp

Add Gulp PostCSS to your build tool:

npm install gulp-postcss --save-dev

Enable Words within your Gulpfile:

var postcss = require('gulp-postcss');

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

Grunt

Add Grunt PostCSS to your build tool:

npm install grunt-postcss --save-dev

Enable Words within your Gruntfile:

grunt.loadNpmTasks('grunt-postcss');

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