Skip to content

Instantly share code, notes, and snippets.

@Langmans
Created September 19, 2016 12:02
Show Gist options
  • Save Langmans/591bfc5f5b829d37bdc738779fd38396 to your computer and use it in GitHub Desktop.
Save Langmans/591bfc5f5b829d37bdc738779fd38396 to your computer and use it in GitHub Desktop.
gulp> scss > autoprefixer > css
/**
* To install:
* install npm
* cd public_html/files/stylesheets
* npm update
*
* to watch:
* gulp
* or to run sass once:
* gulp sass
*/
var gulp = require('gulp');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
// auto adds vendor prefixed props
var autoprefixer = require('gulp-autoprefixer');
var watch = require('gulp-watch');
var input = './**.scss';
var output = '.';
var sassOptions = {
errLogToConsole: true,
outputStyle: 'expanded'
};
// ... variables
var autoprefixerOptions = {
browsers: ['last 5 versions', '> 0.5%'],
// remove outdated props?
remove: false
};
gulp.task('sass', function () {
return gulp
.src(input)
.pipe(sourcemaps.init())
.pipe(sass(sassOptions).on('error', sass.logError))
.pipe(sourcemaps.write())
.pipe(autoprefixer(autoprefixerOptions))
.pipe(gulp.dest(output));
});
gulp.task('default', function () {
console.log('watching for scss file changes...');
gulp.watch(input, ['sass']);
});
{
"name": "stylesheets",
"version": "1.0.0",
"description": "",
"main": "Gulpfile.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"gulp": "^3.9.1",
"gulp-autoprefixer": "^3.1.1",
"gulp-sass": "^2.3.2",
"gulp-sourcemaps": "^1.6.0",
"gulp-watch": "^4.3.9"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment