Skip to content

Instantly share code, notes, and snippets.

@petervmeijgaard
Last active December 16, 2015 11:55
Show Gist options
  • Save petervmeijgaard/010a30ee9e60002d3550 to your computer and use it in GitHub Desktop.
Save petervmeijgaard/010a30ee9e60002d3550 to your computer and use it in GitHub Desktop.
Example Gulpfile
'use strict';
var gulp = require('gulp');
var stylus = require('gulp-stylus');
var sourcemaps = require('gulp-sourcemaps');
var prefix = require('gulp-autoprefixer');
var minifyCss = require('gulp-minify-css');
var rename = require('gulp-rename');
var browserSync = require('browser-sync');
var directories = {
stylus: {
input: './stylus/app.styl',
output: {
folder: './dist',
fileName: 'app.css'
}
},
minify: {
input: './stylus/app.styl',
output: {
folder: './dist',
fileName: 'app.min.css'
}
}
};
gulp.task('stylus', function () {
return gulp
.src(directories.stylus.input)
.pipe(sourcemaps.init())
.pipe(stylus())
.pipe(prefix())
.pipe(rename(directories.stylus.output.fileName))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(directories.stylus.output.folder))
.pipe(browserSync.stream());;
});
gulp.task('minify-css', function () {
return gulp
.src(directories.minify.input)
.pipe(sourcemaps.init())
.pipe(stylus())
.pipe(prefix())
.pipe(minifyCss())
.pipe(rename(directories.minify.output.fileName))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(directories.minify.output.folder));
});
gulp.task('serve', ['styles'], function () {
browserSync.init({
proxy: "localhost" // Setup your server here. By default: localhost:80
});
gulp.watch("assets/stylus/**/*.styl", ['stylus']);
gulp.watch("dist/**/*.html").on('change', browserSync.reload);
});
gulp.task('default', ['stylus', 'minify-css']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment