
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
PostStylus is a PostCSS adapter for Stylus. It allows you to use any PostCSS plugin as a transparent Stylus plugin, and do custom post-processing of Stylus output.
It loads PostCSS processors into Stylus just before the output CSS is compiled to file.
Inspired by autoprefixer-stylus
$ npm install --save-dev poststylus
Use poststylus as a regular stylus plugin and pass it an array of PostCSS plugins you have installed, either as strings or functions.
stylus(css).use(poststylus([
'autoprefixer',
'rucksack-css'
]))
var gulp = require('gulp'),
stylus = require('gulp-stylus'),
poststylus = require('poststylus'),
autoprefixer = require('autoprefixer'),
rucksack = require('rucksack-css');
gulp.task('stylus', function () {
gulp.src('style.styl')
.pipe(stylus({
use: [
poststylus([ autoprefixer, rucksack ])
]
}))
.pipe(gulp.dest('.'))
});
gulp.task('default', ['stylus']);
grunt-contrib-stylus doesn't support passing arguments to plugins, so you have to wrap PostStylus in a function and return it
var postcss = function(){
return require('poststylus')(['autoprefixer', 'rucksack-css']);
}
module.exports = function(grunt) {
grunt.initConfig({
stylus: {
compile: {
options: {
use: [postcss]
},
files: {
'style.css': 'style.styl'
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-stylus');
};
Use stylus-loader with PostStylus as a plugin in your webpack.conf.js
var poststylus = require('poststylus'),
webpack = require('webpack');
module: {
loaders: [
{ test: /\.styl$/, loader: 'style-loader!css-loader!stylus-loader' }
]
},
stylus: {
use: [
poststylus([ 'autoprefixer', 'rucksack-css' ])
]
}
If you are using webpack 2, use LoaderOptionsPlugin to set options
module: {...},
plugins: [
new webpack.LoaderOptionsPlugin({
options: {
stylus: {
use: [poststylus([ 'autoprefixer', 'rucksack-css' ])]
}
}
})
]
To use PostStylus on the Stylus CLI, pass poststylus to --use, and PostCSS plugins to --with:
$ stylus --use ./node_modules/poststylus --with "['autoprefixer']" --out test.css < test.styl
If you need to pass arguments to a PostCSS plugin require() it and pass that function to PostStylus
var autoprefixer = require('autoprefixer');
stylus(css).use([
poststylus([
autoprefixer({ browsers: ['ie 8'] })
])
])
To pass arguments to PostCSS plugins on the CLI, you'll need to prefix require() with $PWD, since the stylus executable runs globally, while your plugins are (probably) installed locally:
stylus --use ./node_modules/poststylus --with "[require('${PWD}/node_modules/autoprefixer')({ browsers: ['ie 8'] })]" --out test.css < test.styl
Do custom post-processing of Stylus output by declaring an on-the-fly PostCSS plugin
var myPostcss = postcss.plugin('custom', function() {
return function (css) {
// PostCSS processing here
};
});
// Pipe it into poststylus
stylus(css).use(poststylus([myPostcss()]));
Refer to the [PostCSS Docs][postcss-link] for more on writing plugins.
By default, if any of your PostCSS plugins raise a warning it will be displayed using console.error. You can override this behaviour by passing a function as the second argument to PostStylus.
stylus(css).use(poststylus([
'autoprefixer',
'rucksack-css'
], function(message) {
console.info(message);
}));
Unfortunately the Stylus end event that PostStylus uses to pass back post-processed CSS doesn't accept a callback, so until this bug is patched upstream PostStylus cannot work with asynchronous PostCSS processing.
MIT © Sean King
FAQs
PostCSS adapter for stylus
The npm package poststylus receives a total of 1,304 weekly downloads. As such, poststylus popularity was classified as popular.
We found that poststylus demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.