postcss-words
v1.0.1
Published
Transform CSS keywords into custom values in CSS
Downloads
4
Readme
Words
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'
}
}
});