0.1.3 • Published 6 years ago
stylus-plugin-minify-words v0.1.3
stylus-plugin-minify-words
A Stylus plugin to shorten words.
Install
npm install stylus-plugin-minify-words --save-dev
Usage
1. Use public(), private() and require() in your stylus-sheet
// button.styl
.{private('ok')}
color green
// style.styl
@require './button'
.{public('header')}
font-size 14px
&>.{require('./button.styl', 'ok')}
color blue
2. Compile stylus-sheet with this plugin
const fs = require('fs');
const {WordMinifier} = require('stylus-plugin-minify-words');
const minifier = new WordMinifier();
stylus(fs.readFileSync('main.styl', 'utf8'))
.use(minifier.plugin())
.render((error, css) => {
console.log(css);
console.log(minifier);
});
You'll get css below.
._0 {
color: green;
}
._1 {
font-size: 14px;
}
._1>._0 {
color: blue;
}
And the minifier has the result.
Map {
'/path/to/button.styl' => Map {
'ok' => {minified: '_0', public: true}
},
'/path/to/style.styl' => Map {
'header' => {minified: '_1', public: true}
}
}
Javascript API
WordMinifier
A WordMinifier
is a Map.<file, words>.
WordMinifier.prototype.plugin()
returns a function passed to .use().
Words
A Words
is a Map.<word, {minified, public}>.
- word: String. The original word.
- minified: String. The minified word.
- public: Boolean. If true, the word is declared by
public()
at least once.
License
MIT