All Projects → madeleineostoja → Poststylus

madeleineostoja / Poststylus

PostCSS adapter for Stylus

Programming Languages

javascript
184084 projects - #8 most used programming language
stylus
462 projects

Projects that are alternatives of or similar to Poststylus

Suit
Style tools for UI components
Stars: ✭ 3,763 (+1248.75%)
Mutual labels:  postcss, preprocessor
Cessie
Transpile your CSS bundle to support CSS variables, calc, and future CSS for legacy browsers.
Stars: ✭ 81 (-70.97%)
Mutual labels:  postcss, preprocessor
Preprocessor
A future-facing CSS preprocessor (used by SUIT CSS)
Stars: ✭ 132 (-52.69%)
Mutual labels:  postcss, preprocessor
antd-color-replacer
适用于 webpack 环境下 的 主题切换插件
Stars: ✭ 22 (-92.11%)
Mutual labels:  postcss
polymerx-cli
⚡ Unlock the power of Polymer 3, Web Components and modern web tools.
Stars: ✭ 30 (-89.25%)
Mutual labels:  postcss
storify
Instagram/Whatsapp stories clone built on Web Components and Web Animations API. 🔥
Stars: ✭ 64 (-77.06%)
Mutual labels:  postcss
Shopify Theme Lab
Shopify theme development environment using Liquid, Vue and Tailwind CSS 🧪
Stars: ✭ 250 (-10.39%)
Mutual labels:  postcss
postcss-each
PostCSS plugin to iterate through values
Stars: ✭ 93 (-66.67%)
Mutual labels:  postcss
sapper-template-rollup
Starter Rollup template for Sapper apps using postcss, cssnano, tailwindcss, and svelte-preprocess.
Stars: ✭ 32 (-88.53%)
Mutual labels:  postcss
xcc
Toy C compiler for x86-64
Stars: ✭ 19 (-93.19%)
Mutual labels:  preprocessor
tailpress
A Tailwind CSS enabled Underscores theme
Stars: ✭ 60 (-78.49%)
Mutual labels:  postcss
sapper-postcss-template
A template that includes Sapper for Svelte and PostCSS preprocessing with Tailwind CSS
Stars: ✭ 84 (-69.89%)
Mutual labels:  postcss
react-enterprise-starter-kit
Highly Scalable Awesome React Starter Kit for an enterprise application with a very easy maintainable codebase. 🔥
Stars: ✭ 55 (-80.29%)
Mutual labels:  postcss
dmr c
dmr_C is a C parser and JIT compiler with LLVM, Eclipse OMR and NanoJIT backends
Stars: ✭ 45 (-83.87%)
Mutual labels:  preprocessor
edgestack
[UNMAINTAINED] A Universal React Stack with deeply integrated localization Support, semi-automatic route-based code splitting, Hot Module Reloading (HMR), Redux, Apollo GraphQL and more...
Stars: ✭ 77 (-72.4%)
Mutual labels:  postcss
eleventy solo starter njk
Further development suspended as of 2021-09-11. Please refer instead to https://www.11ty.dev/docs/starter/ for a wide selection of other Eleventy starter sets.
Stars: ✭ 22 (-92.11%)
Mutual labels:  postcss
tailwind-airbnb
A demo of how to build Airbnb's home page using Tailwind CSS
Stars: ✭ 39 (-86.02%)
Mutual labels:  postcss
postcss-font-grabber
A postcss plugin, it grabs remote font files and update your CSS, just like that.
Stars: ✭ 26 (-90.68%)
Mutual labels:  postcss
XT-TailwindCSS-Starter
A Tailwind CSS Starter. Based on Tailwind CSS, Webpack, PostCSS, and cssnano. Fully optimized for top performance.
Stars: ✭ 19 (-93.19%)
Mutual labels:  postcss
postcss-rs
🚀 Fast and 100% API compatible postcss replacer, built in Rust
Stars: ✭ 414 (+48.39%)
Mutual labels:  postcss

PostStylus

NPM version NPM downloads Build Status

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

Contents

Install

$ npm install --save-dev poststylus

Usage

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'
]))

Gulp

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

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');

};

Webpack

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' ])]
      }
    }
  })
]

CLI

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

Passing Arguments to Plugins

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

Custom Processing

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.

Warning Handler

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);
}));

Asynchronous Processing

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].