Stylus task for Grunt.

Stylus task for Grunt

Inside your grunt.js file add a section named stylus. This section specifies the files to compile and the options passed to Stylus.

This defines what files this task will process and should contain key:value pairs.

The key (destination) should be an unique filepath (supports grunt.template) and the value (source) should be a filepath or an array of filepaths (supports minimatch).

Note: When the value contains an array of multiple filepaths, the contents are concatenated in the order passed.

This controls how this task (and its helpers) operate and should contain key:value pairs, see options below.

This specifies if we should compress the compiled css.

This specifies directories to scan for @import directives when parsing.

stylus: {
  compile: {
    options: {
      'compress': true,
      'include css': true,
      'paths': ['path/to/import', 'another/to/import']
    files: {
      'path/to/result.css': 'path/to/source.styl',
      'path/to/another.css': ['path/to/sources/*.styl', 'path/to/more/*.style'],

You can use url() function for embedding images as data:uri. You can define any name for it.

options: {
  urlfunc: "embedurl"

Now you can write in Stylus files:


Based on grunt-contrib’s stylus task by Eric Woroshow, modified by Artem Sapegin.

The MIT License, see the included file.