first commit
This commit is contained in:
+56
@@ -0,0 +1,56 @@
|
||||
'use strict';
|
||||
const fancyLog = require('fancy-log');
|
||||
const PluginError = require('plugin-error');
|
||||
const through = require('through2');
|
||||
const applySourceMap = require('vinyl-sourcemaps-apply');
|
||||
const autoprefixer = require('autoprefixer');
|
||||
const postcss = require('postcss');
|
||||
|
||||
module.exports = opts => {
|
||||
return through.obj((file, enc, cb) => {
|
||||
if (file.isNull()) {
|
||||
cb(null, file);
|
||||
return;
|
||||
}
|
||||
|
||||
if (file.isStream()) {
|
||||
cb(new PluginError('gulp-autoprefixer', 'Streaming not supported'));
|
||||
return;
|
||||
}
|
||||
|
||||
postcss(autoprefixer(opts)).process(file.contents.toString(), {
|
||||
map: file.sourceMap ? {annotation: false} : false,
|
||||
from: file.path,
|
||||
to: file.path
|
||||
}).then(res => {
|
||||
file.contents = Buffer.from(res.css);
|
||||
|
||||
if (res.map && file.sourceMap) {
|
||||
const map = res.map.toJSON();
|
||||
map.file = file.relative;
|
||||
map.sources = map.sources.map(() => file.relative);
|
||||
applySourceMap(file, map);
|
||||
}
|
||||
|
||||
const warnings = res.warnings();
|
||||
|
||||
if (warnings.length > 0) {
|
||||
fancyLog('gulp-autoprefixer:', '\n ' + warnings.join('\n '));
|
||||
}
|
||||
|
||||
setImmediate(cb, null, file);
|
||||
}).catch(error => {
|
||||
const cssError = error.name === 'CssSyntaxError';
|
||||
|
||||
if (cssError) {
|
||||
error.message += error.showSourceCode();
|
||||
}
|
||||
|
||||
// Prevent stream unhandled exception from being suppressed by Promise
|
||||
setImmediate(cb, new PluginError('gulp-autoprefixer', error, {
|
||||
fileName: file.path,
|
||||
showStack: !cssError
|
||||
}));
|
||||
});
|
||||
});
|
||||
};
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
{
|
||||
"_from": "gulp-autoprefixer@latest",
|
||||
"_id": "gulp-autoprefixer@6.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-MyLymXKVGTVBx/okQSBqmdhwhyqi3igBmZBwgpZp0GRbY1LY8VctOTLzwkQ18bZKJkSDnOKR5u32TMY9wSYdqQ==",
|
||||
"_location": "/gulp-autoprefixer",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "tag",
|
||||
"registry": true,
|
||||
"raw": "gulp-autoprefixer@latest",
|
||||
"name": "gulp-autoprefixer",
|
||||
"escapedName": "gulp-autoprefixer",
|
||||
"rawSpec": "latest",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "latest"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"#DEV:/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/gulp-autoprefixer/-/gulp-autoprefixer-6.0.0.tgz",
|
||||
"_shasum": "7034ef12c24a92a5b20158d63623ebbd900faed8",
|
||||
"_spec": "gulp-autoprefixer@latest",
|
||||
"_where": "/home/kevin/Documents/Sites/figureslibres.net/user/themes/figureslibres",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/sindresorhus/gulp-autoprefixer/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"autoprefixer": "^9.1.3",
|
||||
"fancy-log": "^1.3.2",
|
||||
"plugin-error": "^1.0.1",
|
||||
"postcss": "^7.0.2",
|
||||
"through2": "^2.0.0",
|
||||
"vinyl-sourcemaps-apply": "^0.2.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Prefix CSS",
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"gulp-sourcemaps": "^2.6.0",
|
||||
"p-event": "^2.1.0",
|
||||
"vinyl": "^2.1.0",
|
||||
"xo": "*"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/sindresorhus/gulp-autoprefixer#readme",
|
||||
"keywords": [
|
||||
"gulpplugin",
|
||||
"autoprefixer",
|
||||
"postcss",
|
||||
"css",
|
||||
"prefix",
|
||||
"prefixes",
|
||||
"stylesheet",
|
||||
"preprocess",
|
||||
"postcss-runner"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "gulp-autoprefixer",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/sindresorhus/gulp-autoprefixer.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"version": "6.0.0"
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
# gulp-autoprefixer [](https://travis-ci.org/sindresorhus/gulp-autoprefixer)
|
||||
|
||||
> Prefix CSS with [Autoprefixer](https://github.com/postcss/autoprefixer)
|
||||
|
||||
*Issues with the output should be reported on the Autoprefixer [issue tracker](https://github.com/postcss/autoprefixer/issues).*
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save-dev gulp-autoprefixer
|
||||
```
|
||||
|
||||
<a href="https://www.patreon.com/sindresorhus">
|
||||
<img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" width="160">
|
||||
</a>
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const gulp = require('gulp');
|
||||
const autoprefixer = require('gulp-autoprefixer');
|
||||
|
||||
gulp.task('default', () =>
|
||||
gulp.src('src/app.css')
|
||||
.pipe(autoprefixer({
|
||||
browsers: ['last 2 versions'],
|
||||
cascade: false
|
||||
}))
|
||||
.pipe(gulp.dest('dist'))
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### autoprefixer([options])
|
||||
|
||||
#### options
|
||||
|
||||
Type: `Object`
|
||||
|
||||
See the Autoprefixer [options](https://github.com/postcss/autoprefixer#options).
|
||||
|
||||
|
||||
## Source Maps
|
||||
|
||||
Use [gulp-sourcemaps](https://github.com/gulp-sourcemaps/gulp-sourcemaps) like this:
|
||||
|
||||
```js
|
||||
const gulp = require('gulp');
|
||||
const sourcemaps = require('gulp-sourcemaps');
|
||||
const autoprefixer = require('gulp-autoprefixer');
|
||||
const concat = require('gulp-concat');
|
||||
|
||||
gulp.task('default', () =>
|
||||
gulp.src('src/**/*.css')
|
||||
.pipe(sourcemaps.init())
|
||||
.pipe(autoprefixer())
|
||||
.pipe(concat('all.css'))
|
||||
.pipe(sourcemaps.write('.'))
|
||||
.pipe(gulp.dest('dist'))
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
## Tip
|
||||
|
||||
If you use other PostCSS based tools, like `cssnano`, you may want to run them together using [`gulp-postcss`](https://github.com/postcss/autoprefixer#gulp) instead of `gulp-autoprefixer`. It will be faster, as the CSS is parsed only once for all PostCSS based tools, including Autoprefixer.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
Reference in New Issue
Block a user