You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+22-2Lines changed: 22 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,17 +7,37 @@ Gulp plugin for mapping sources of a sourcemap.
7
7
## Example
8
8
9
9
```js
10
-
// TODO
10
+
var mapSources =require('@gulp-sourcemaps/map-sources');
11
+
12
+
gulp.src(...)
13
+
.pipe(sourcemaps.init())
14
+
.pipe(mapSources(function(sourcePath, file) {
15
+
return'../'+ sourcePath;
16
+
}))
17
+
.pipe(sourcemaps.write())
18
+
.pipe(gulp.dest(...))
11
19
```
12
20
13
21
## API
14
22
15
-
### `TODO`
23
+
### `mapSources(mapFn)`
24
+
25
+
Takes a map function as the only argument. Returns an `objectMode` Transform stream.
26
+
27
+
#### `mapFn(sourcePath, file)`
28
+
29
+
The map function is called once per value of the `sources` array of a `sourceMap` attached to each [`Vinyl`][vinyl-url] object passed through the stream. The map function is called with the `sourcePath` string from the `sources` array and the `file` object it originated from. The return value replaces the original value in the array.
30
+
31
+
If a `Vinyl` object doesn't have a `sourceMap` or `sourceMap.sources` property, the file is passed through the stream without having the `mapFn` called.
32
+
33
+
All `sources` are normalized to use `/` instead of `\\` as path separators.
0 commit comments