gulp-autoprefixer
Advanced tools
Comparing version 2.2.0 to 2.3.0
51
index.js
'use strict'; | ||
var gutil = require('gulp-util'); | ||
var through = require('through2'); | ||
var autoprefixer = require('autoprefixer-core'); | ||
var applySourceMap = require('vinyl-sourcemaps-apply'); | ||
var objectAssign = require('object-assign'); | ||
var autoprefixer = require('autoprefixer-core'); | ||
var postcss = require('postcss'); | ||
var CssSyntaxError = require('postcss/lib/css-syntax-error'); | ||
module.exports = function (opts) { | ||
opts = opts || {}; | ||
return through.obj(function (file, enc, cb) { | ||
@@ -24,30 +21,28 @@ if (file.isNull()) { | ||
try { | ||
var fileOpts = objectAssign({}, opts); | ||
var processor = postcss() | ||
.use(autoprefixer(fileOpts)) | ||
.process(file.contents.toString(), { | ||
map: file.sourceMap ? {annotation: false} : false, | ||
from: file.path, | ||
to: file.path | ||
}); | ||
var fileOpts = objectAssign({}, opts); | ||
var processor = postcss() | ||
.use(autoprefixer(fileOpts)) | ||
.process(file.contents.toString(), { | ||
map: file.sourceMap ? {annotation: false} : false, | ||
from: file.path, | ||
to: file.path | ||
}); | ||
processor.then(function (res) { | ||
file.contents = new Buffer(res.css); | ||
processor.then(function (res) { | ||
file.contents = new Buffer(res.css); | ||
if (res.map && file.sourceMap) { | ||
applySourceMap(file, res.map.toString()); | ||
} | ||
if (res.map && file.sourceMap) { | ||
applySourceMap(file, res.map.toString()); | ||
} | ||
if (res.warnings && res.warnings()) { | ||
res.warnings().forEach(function (warn) { | ||
gutil.log(warn.toString()); | ||
}); | ||
} | ||
var warnings = res.warnings(); | ||
cb(null, file); | ||
}); | ||
} catch (err) { | ||
var cssError = err instanceof CssSyntaxError; | ||
if (warnings.length > 0) { | ||
gutil.log('gulp-autoprefixer:', '\n ' + warnings.join('\n ')); | ||
} | ||
cb(null, file); | ||
}).catch(function (err) { | ||
var cssError = err.name === 'CssSyntaxError'; | ||
if (cssError) { | ||
@@ -61,4 +56,4 @@ err.message = err.message + err.showSourceCode(); | ||
})); | ||
} | ||
}); | ||
}); | ||
}; |
{ | ||
"name": "gulp-autoprefixer", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"description": "Prefix CSS", | ||
@@ -30,3 +30,3 @@ "license": "MIT", | ||
"preprocess", | ||
"postcssrunner" | ||
"postcss-runner" | ||
], | ||
@@ -33,0 +33,0 @@ "dependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5099
47