Skip to content

Commit 6ac3e3b

Browse files
committed
docs(README): refresh README with gulp4 usage
1 parent f37dd75 commit 6ac3e3b

File tree

1 file changed

+68
-31
lines changed

1 file changed

+68
-31
lines changed

README.md

Lines changed: 68 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
55
[![unassert][unassert-banner]][unassert-url]
66

7-
[![NPM version][npm-image]][npm-url]
87
[![Build Status][travis-image]][travis-url]
9-
[![Dependency Status][depstat-image]][depstat-url]
8+
[![NPM version][npm-image]][npm-url]
9+
[![Code Style][style-image]][style-url]
1010
[![License][license-image]][license-url]
1111

1212

@@ -24,51 +24,88 @@
2424
- [unassert-cli](https://github.com/unassert-js/unassert-cli): CLI for unassert
2525

2626

27-
## Usage
28-
29-
First, install `gulp-unassert` as a devDependencies:
27+
## Install
3028

3129
```shell
3230
npm install --save-dev gulp-unassert
3331
```
3432

35-
Then, add it to your `gulpfile.js`:
33+
## Usage
34+
35+
### gulp 3.x
3636

3737
```javascript
38-
var unassert = require('gulp-unassert');
38+
const unassert = require('gulp-unassert');
3939

40-
gulp.task('build', function () {
41-
gulp.src('./src/*.js')
42-
.pipe(unassert())
43-
.pipe(gulp.dest('./dist'));
40+
gulp.task('build', () => {
41+
gulp.src('./src/*.js')
42+
.pipe(unassert())
43+
.pipe(gulp.dest('./dist'));
4444
});
4545
```
4646

47+
### gulp 4.x
48+
49+
```javascript
50+
const { src, dest } = require('gulp');
51+
const unassert = require('gulp-unassert');
52+
53+
function build() {
54+
return src('./src/*.js')
55+
.pipe(unassert())
56+
.pipe(dest('./dist'));
57+
}
58+
exports.build = build;
59+
```
60+
4761

4862
## Source maps
4963

50-
gulp-unassert can be used with [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps) to generate source maps for the transformed javascript code. Note that you should `init` gulp-sourcemaps prior to running the gulp-unassert and `write` the source maps after. gulp-unassert works well with some gulp plugins that supports [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps).
64+
### gulp 3.x
65+
66+
gulp-unassert can be used with [gulp-sourcemaps](https://github.com/gulp-sourcemaps/gulp-sourcemaps) to generate source maps for the transformed javascript code. Note that you should `init` gulp-sourcemaps prior to running the gulp-unassert and `write` the source maps after. gulp-unassert works well with some gulp plugins that supports [gulp-sourcemaps](https://github.com/gulp-sourcemaps/gulp-sourcemaps).
5167

5268
```javascript
53-
var unassert = require('gulp-unassert');
54-
var coffee = require('gulp-coffee');
55-
var concat = require('gulp-concat');
56-
var sourcemaps = require('gulp-sourcemaps');
57-
58-
gulp.task('build', function () {
59-
// compile, instrument then concatinate
60-
gulp.src('./src/**/*.coffee')
61-
.pipe(sourcemaps.init())
62-
.pipe(coffee({bare: true}))
63-
.pipe(unassert())
64-
.pipe(concat('bundle.js'))
65-
.pipe(sourcemaps.write())
66-
.pipe(gulp.dest('./build'));
67-
// will write the source maps inline in the code
69+
const unassert = require('gulp-unassert');
70+
const coffee = require('gulp-coffee');
71+
const concat = require('gulp-concat');
72+
const sourcemaps = require('gulp-sourcemaps');
73+
74+
gulp.task('build', () => {
75+
// compile, instrument then concatinate
76+
gulp.src('./src/**/*.coffee')
77+
.pipe(sourcemaps.init())
78+
.pipe(coffee({bare: true}))
79+
.pipe(unassert())
80+
.pipe(concat('bundle.js'))
81+
.pipe(sourcemaps.write())
82+
.pipe(gulp.dest('./build'));
83+
// will write the source maps inline in the code
6884
});
6985
```
7086

71-
For more information, see [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps).
87+
For more information, see [gulp-sourcemaps](https://github.com/gulp-sourcemaps/gulp-sourcemaps).
88+
89+
90+
### gulp 4.x
91+
92+
In gulp 4, sourcemaps are built-in by default.
93+
94+
```javascript
95+
const { src, dest } = require('gulp');
96+
const unassert = require('gulp-unassert');
97+
const coffee = require('gulp-coffee');
98+
const concat = require('gulp-concat');
99+
100+
function build() {
101+
return src('./src/*.coffee', { sourcemaps: true })
102+
.pipe(coffee({ bare: true }))
103+
.pipe(unassert())
104+
.pipe(concat('bundle.js'))
105+
.pipe(dest('./build'));
106+
}
107+
exports.build = build;
108+
```
72109

73110

74111
## Changelog
@@ -104,8 +141,8 @@ Licensed under the [MIT](https://github.com/unassert-js/gulp-unassert/blob/maste
104141
[travis-url]: https://travis-ci.org/unassert-js/gulp-unassert
105142
[travis-image]: https://secure.travis-ci.org/unassert-js/gulp-unassert.svg?branch=master
106143

107-
[depstat-url]: https://gemnasium.com/unassert-js/gulp-unassert
108-
[depstat-image]: https://gemnasium.com/unassert-js/gulp-unassert.svg
109-
110144
[license-url]: https://github.com/unassert-js/gulp-unassert/blob/master/LICENSE-MIT
111145
[license-image]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat
146+
147+
[style-url]: https://github.com/Flet/semistandard
148+
[style-image]: https://img.shields.io/badge/code%20style-semistandard-brightgreen.svg

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy