jescalan / rupture

Simple media queries in stylus

Home Page:http://jescalan.github.io/rupture

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to use rupture + gulp?

wad2eq opened this issue · comments

All in subject
How to use rupture + gulp?

You can configure this inside your gulpfile.js file.

I have stripped all the other tasks and dependencies from my gulpfile so that you can see how I have configured my build task to use gulp + stylus + rupture + jeet + autoprefixer:

var argv         = require('yargs').argv;
var autoprefixer = require('autoprefixer-stylus');
var gulp         = require('gulp');
var jeet         = require('jeet');
var rename       = require('gulp-rename');
var rupture      = require('rupture');
var stylus       = require('gulp-stylus');

function buildCssHelper() {
    var options = {
        use: [ jeet(), rupture(), autoprefixer() ]
    };

    if (!argv.production) {
        options.sourcemap = {
            inline: true,
            sourceRoot: '.',
            basePath: 'css'
        };
    }
    else {
        options.compress = true;
    }

    gulp.src('./stylus/main.styl')
        .pipe(stylus(options))
        .pipe(rename(argv.production ? 'main.min.css' : 'main.css'))
        .pipe(gulp.dest('../public/css'));
}

function buildCssTask() {
    buildCssHelper();

    if (argv.watch)
        gulp.watch('./stylus/**/*.styl', function() {
            buildCssHelper();
        })
}

gulp.task('build-css', buildCssTask);

Notice that I have also used gulp.watch after the initial build when --watch is passed in as a command line argument, but this is entirely optional.

I hope that this helps! Let me know if you have any questions and I will do my best to assist :)

Thanks for such a great answer @rotorz! Just to add my two cents, you can use either gulp-stylus or gulp-accord. Both of these plugins use accord behind the scenes for parsing stylus' options.

The trick is really just in the use line in the example @rotorz posted above. All you need to do is require rupture and use it with stylus, and you're set.

Closing this issue as there are solid responses and solutions here but feel free to follow up if you're still having trouble!

Great:)
Thanks I will try.