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
+59-28Lines changed: 59 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,8 @@ Sourcemap support for gulpjs.
6
6
7
7
### Usage
8
8
9
+
All the examples here works with Gulp 4. To see examples related to Gulp 3, [you can read them here](https://github.com/gulp-sourcemaps/gulp-sourcemaps/blob/v2.6.5/README.md).
10
+
9
11
#### Write inline source maps
10
12
Inline source maps are embedded in the source file.
11
13
@@ -16,14 +18,17 @@ var plugin1 = require('gulp-plugin1');
16
18
var plugin2 =require('gulp-plugin2');
17
19
var sourcemaps =require('gulp-sourcemaps');
18
20
19
-
gulp.task('javascript', function() {
21
+
functionjavascript() {
20
22
gulp.src('src/**/*.js')
21
23
.pipe(sourcemaps.init())
22
24
.pipe(plugin1())
23
25
.pipe(plugin2())
24
26
.pipe(sourcemaps.write())
25
27
.pipe(gulp.dest('dist'));
26
-
});
28
+
};
29
+
30
+
31
+
exports.javascript= javascript;
27
32
```
28
33
29
34
All plugins between `sourcemaps.init()` and `sourcemaps.write()` need to have support for `gulp-sourcemaps`. You can find a list of such plugins in the [wiki](https://github.com/gulp-sourcemaps/gulp-sourcemaps/wiki/Plugins-with-gulp-sourcemaps-support).
@@ -40,14 +45,16 @@ var plugin1 = require('gulp-plugin1');
40
45
var plugin2 =require('gulp-plugin2');
41
46
var sourcemaps =require('gulp-sourcemaps');
42
47
43
-
gulp.task('javascript', function() {
48
+
functionjavascript() {
44
49
gulp.src('src/**/*.js')
45
50
.pipe(sourcemaps.init())
46
51
.pipe(plugin1())
47
52
.pipe(plugin2())
48
53
.pipe(sourcemaps.write('../maps'))
49
54
.pipe(gulp.dest('dist'));
50
-
});
55
+
};
56
+
57
+
exports.javascript= javascript;
51
58
```
52
59
53
60
#### Load existing source maps
@@ -61,14 +68,16 @@ var plugin1 = require('gulp-plugin1');
61
68
var plugin2 =require('gulp-plugin2');
62
69
var sourcemaps =require('gulp-sourcemaps');
63
70
64
-
gulp.task('javascript', function() {
71
+
functionjavascript() {
65
72
gulp.src('src/**/*.js')
66
73
.pipe(sourcemaps.init({loadMaps:true}))
67
74
.pipe(plugin1())
68
75
.pipe(plugin2())
69
76
.pipe(sourcemaps.write())
70
77
.pipe(gulp.dest('dist'));
71
-
});
78
+
};
79
+
80
+
exports.javascript= javascript;
72
81
```
73
82
74
83
#### Handle large files
@@ -82,14 +91,16 @@ var plugin1 = require('gulp-plugin1');
82
91
var plugin2 =require('gulp-plugin2');
83
92
var sourcemaps =require('gulp-sourcemaps');
84
93
85
-
gulp.task('javascript', function() {
94
+
functionjavascript() {
86
95
gulp.src('src/**/*.js')
87
96
.pipe(sourcemaps.init({largeFile:true}))
88
97
.pipe(plugin1())
89
98
.pipe(plugin2())
90
99
.pipe(sourcemaps.write())
91
100
.pipe(gulp.dest('dist'));
92
-
});
101
+
};
102
+
103
+
exports.javascript= javascript;
93
104
```
94
105
95
106
#### Handle source files from different directories
@@ -103,14 +114,16 @@ var plugin1 = require('gulp-plugin1');
In this case for a file written to `dist/subdir/example.js`, the source map is written to `dist/subdir/example.js.map` and the sourceRoot will be `../../src` (resulting in the full source path `../../src/subdir/example.js`).
0 commit comments