Created
August 19, 2016 03:44
-
-
Save nicksheffield/7b8525973ab4cf59e4cce1c4c93061f0 to your computer and use it in GitHub Desktop.
Gulp with sass or stylus
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var gulp = require('gulp') | |
| var minify = require('gulp-clean-css') | |
| var autoprefix = require('gulp-autoprefixer') | |
| var rename = require('gulp-rename') | |
| var stylus = require('gulp-stylus') | |
| var sass = require('gulp-sass') | |
| var plumber = require('gulp-plumber') | |
| var notify = require('gulp-notify') | |
| var gulpif = require('gulp-if') | |
| var path = require('path') | |
| var paths = { | |
| css: { | |
| files: 'before/*.styl', | |
| main: 'before/style.styl' | |
| }, | |
| output: 'after/' | |
| } | |
| var plumberOpts = { | |
| errorHandler: notify.onError("Error: <%= error.message %>") | |
| } | |
| gulp.task('css', function() { | |
| var stream = gulp.src(paths.css.main) | |
| .pipe(plumber(plumberOpts)) | |
| .pipe(gulpif(path.extname(paths.css.main) == '.styl', stylus())) | |
| .pipe(gulpif(path.extname(paths.css.main) == '.scss', sass())) | |
| .pipe(autoprefix()) | |
| .pipe(gulp.dest(paths.output)) | |
| .pipe(minify()) | |
| .pipe(rename('style.min.css')) | |
| .pipe(gulp.dest(paths.output)) | |
| return stream | |
| }) | |
| gulp.task('watch', ['css'], function() { | |
| gulp.watch(paths.css.files, ['css']) | |
| }) | |
| gulp.task('default', ['css'], function() { | |
| console.log('Ready to go'); | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "gulp-test", | |
| "version": "1.0.0", | |
| "description": "", | |
| "main": "index.js", | |
| "scripts": { | |
| "test": "echo \"Error: no test specified\" && exit 1" | |
| }, | |
| "keywords": [], | |
| "author": "Nick Sheffield <[email protected]> (http://nicksheffield.me/)", | |
| "license": "MIT", | |
| "dependencies": { | |
| "gulp": "^3.9.1", | |
| "gulp-autoprefixer": "^3.1.1", | |
| "gulp-clean-css": "^2.0.12", | |
| "gulp-if": "^2.0.1", | |
| "gulp-notify": "^2.2.0", | |
| "gulp-plumber": "^1.1.0", | |
| "gulp-rename": "^1.2.2", | |
| "gulp-sass": "^2.3.2", | |
| "gulp-stylus": "^2.5.0" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment