|
4 | 4 |
|
5 | 5 | [![unassert][unassert-banner]][unassert-url]
|
6 | 6 |
|
7 |
| -[![NPM version][npm-image]][npm-url] |
8 | 7 | [![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] |
10 | 10 | [![License][license-image]][license-url]
|
11 | 11 |
|
12 | 12 |
|
|
24 | 24 | - [unassert-cli](https://github.com/unassert-js/unassert-cli): CLI for unassert
|
25 | 25 |
|
26 | 26 |
|
27 |
| -## Usage |
28 |
| - |
29 |
| -First, install `gulp-unassert` as a devDependencies: |
| 27 | +## Install |
30 | 28 |
|
31 | 29 | ```shell
|
32 | 30 | npm install --save-dev gulp-unassert
|
33 | 31 | ```
|
34 | 32 |
|
35 |
| -Then, add it to your `gulpfile.js`: |
| 33 | +## Usage |
| 34 | + |
| 35 | +### gulp 3.x |
36 | 36 |
|
37 | 37 | ```javascript
|
38 |
| -var unassert = require('gulp-unassert'); |
| 38 | +const unassert = require('gulp-unassert'); |
39 | 39 |
|
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')); |
44 | 44 | });
|
45 | 45 | ```
|
46 | 46 |
|
| 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 | + |
47 | 61 |
|
48 | 62 | ## Source maps
|
49 | 63 |
|
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). |
51 | 67 |
|
52 | 68 | ```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 |
68 | 84 | });
|
69 | 85 | ```
|
70 | 86 |
|
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 | +``` |
72 | 109 |
|
73 | 110 |
|
74 | 111 | ## Changelog
|
@@ -104,8 +141,8 @@ Licensed under the [MIT](https://github.com/unassert-js/gulp-unassert/blob/maste
|
104 | 141 | [travis-url]: https://travis-ci.org/unassert-js/gulp-unassert
|
105 | 142 | [travis-image]: https://secure.travis-ci.org/unassert-js/gulp-unassert.svg?branch=master
|
106 | 143 |
|
107 |
| -[depstat-url]: https://gemnasium.com/unassert-js/gulp-unassert |
108 |
| -[depstat-image]: https://gemnasium.com/unassert-js/gulp-unassert.svg |
109 |
| - |
110 | 144 | [license-url]: https://github.com/unassert-js/gulp-unassert/blob/master/LICENSE-MIT
|
111 | 145 | [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