Skip to content

Instantly share code, notes, and snippets.

@mcattx
Created November 8, 2016 08:59
Show Gist options
  • Save mcattx/5c13c1813930ed62404c4a6145a2f50e to your computer and use it in GitHub Desktop.
Save mcattx/5c13c1813930ed62404c4a6145a2f50e to your computer and use it in GitHub Desktop.
Using postcss and autoprefixer in Gulp
var gulp = require('gulp'),
// html
// css
postcss = require('gulp-postcss'),
sourcemaps = require('gulp-sourcemaps'),
precss = require('precss'),
autoprefixer = require('autoprefixer'),
cssnext = require('postcss-cssnext'),
// js
// debug
debug = require('gulp-debug');
gulp.task('css', function() {
// 定义 Postcsss 任务流数组
var processors = [
autoprefixer({
browsers: ['> 0.1%', 'Android >= 4.0']
}),
precss(),
cssnext()
];
return gulp.src('./src/**/*.css')
.pipe(debug({title: 'check the file: '}))
.pipe(postcss(processors))
.pipe(gulp.dest('./dist'))
})
gulp.task('dev', ['css']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment