New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update dependencies and move to ESM #267
Merged
Merged
Changes from 8 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
eaf3bd3
Update Node test matrix
pioug 90edf9c
Update through2@4.0.2
pioug e23c31b
Update plugin-error@2.0.1
pioug 06781d2
Update vinyl@3.0.0
pioug 9ba4fc9
Require node>=14 in package.json
pioug 53269bb
Update dependencies and move to ESM
pioug b77b437
Update examples in README.md
pioug 59c5e4e
Replace through2 with easy-transform-stream
pioug 3357102
Require node>=16
pioug 39e09fa
Import default 'gulp' in examples
pioug 553466b
Ensure correct file count during tests
pioug 1d6480d
Update examples in readme
pioug File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,13 +16,13 @@ $ npm install --save-dev gulp-rev | |
## Usage | ||
|
||
```js | ||
const gulp = require('gulp'); | ||
const rev = require('gulp-rev'); | ||
import {src, dest} from 'gulp'; | ||
import rev from 'gulp-rev'; | ||
|
||
exports.default = () => ( | ||
gulp.src('src/*.css') | ||
export default () => ( | ||
src('src/*.css') | ||
.pipe(rev()) | ||
.pipe(gulp.dest('dist')) | ||
.pipe(dest('dist')) | ||
); | ||
``` | ||
|
||
|
@@ -83,18 +83,18 @@ The hash of each rev'd file is stored at `file.revHash`. You can use this for cu | |
### Asset manifest | ||
|
||
```js | ||
const gulp = require('gulp'); | ||
const rev = require('gulp-rev'); | ||
import {src, dest} from 'gulp'; | ||
import rev from 'gulp-rev'; | ||
|
||
exports.default = () => ( | ||
export default = () => ( | ||
// By default, Gulp would pick `assets/css` as the base, | ||
// so we need to set it explicitly: | ||
gulp.src(['assets/css/*.css', 'assets/js/*.js'], {base: 'assets'}) | ||
.pipe(gulp.dest('build/assets')) // Copy original assets to build dir | ||
src(['assets/css/*.css', 'assets/js/*.js'], {base: 'assets'}) | ||
.pipe(dest('build/assets')) // Copy original assets to build dir | ||
.pipe(rev()) | ||
.pipe(gulp.dest('build/assets')) // Write rev'd assets to build dir | ||
.pipe(dest('build/assets')) // Write rev'd assets to build dir | ||
.pipe(rev.manifest()) | ||
.pipe(gulp.dest('build/assets')) // Write manifest to build dir | ||
.pipe(dest('build/assets')) // Write manifest to build dir | ||
); | ||
``` | ||
|
||
|
@@ -110,21 +110,21 @@ An asset manifest, mapping the original paths to the revisioned paths, will be w | |
By default, `rev-manifest.json` will be replaced as a whole. To merge with an existing manifest, pass `merge: true` and the output destination (as `base`) to `rev.manifest()`: | ||
|
||
```js | ||
const gulp = require('gulp'); | ||
const rev = require('gulp-rev'); | ||
import {src, dest} from 'gulp'; | ||
import rev from 'gulp-rev'; | ||
|
||
exports.default = () => ( | ||
export default = () => ( | ||
// By default, Gulp would pick `assets/css` as the base, | ||
// so we need to set it explicitly: | ||
gulp.src(['assets/css/*.css', 'assets/js/*.js'], {base: 'assets'}) | ||
.pipe(gulp.dest('build/assets')) | ||
src(['assets/css/*.css', 'assets/js/*.js'], {base: 'assets'}) | ||
.pipe(dest('build/assets')) | ||
.pipe(rev()) | ||
.pipe(gulp.dest('build/assets')) | ||
.pipe(dest('build/assets')) | ||
.pipe(rev.manifest({ | ||
base: 'build/assets', | ||
merge: true // Merge with the existing manifest if one exists | ||
})) | ||
.pipe(gulp.dest('build/assets')) | ||
.pipe(dest('build/assets')) | ||
); | ||
``` | ||
|
||
|
@@ -136,18 +136,18 @@ Because of the way `gulp-concat` handles file paths, you may need to set `cwd` a | |
|
||
```js | ||
const gulp = require('gulp'); | ||
const rev = require('gulp-rev'); | ||
const sourcemaps = require('gulp-sourcemaps'); | ||
const concat = require('gulp-concat'); | ||
|
||
exports.default = () => ( | ||
gulp.src('src/*.js') | ||
exports.default = async () => { | ||
const {default: rev} = await import('gulp-rev'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why dynamic import? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 鉃★笍 1d6480d My mistake, I thought that we couldn't import the other packages of the examples using ES import |
||
return gulp.src('src/*.js') | ||
.pipe(sourcemaps.init()) | ||
.pipe(concat({path: 'bundle.js', cwd: ''})) | ||
.pipe(rev()) | ||
.pipe(sourcemaps.write('.')) | ||
.pipe(gulp.dest('dist')) | ||
); | ||
}; | ||
``` | ||
|
||
## Different hash for unchanged files | ||
|
@@ -167,16 +167,16 @@ const gulp = require('gulp'); | |
const browserify = require('browserify'); | ||
const source = require('vinyl-source-stream'); | ||
const buffer = require('gulp-buffer'); | ||
const rev = require('gulp-rev'); | ||
|
||
exports.default = () => ( | ||
browserify('src/index.js') | ||
exports.default = async () => { | ||
const {default: rev} = await import('gulp-rev'); | ||
return browserify('src/index.js') | ||
.bundle({debug: true}) | ||
.pipe(source('index.min.js')) | ||
.pipe(buffer()) | ||
.pipe(rev()) | ||
.pipe(gulp.dest('dist')) | ||
); | ||
}; | ||
``` | ||
|
||
## Integration | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to keep
gulp
a default import.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
鉃★笍 39e09fa