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
+44-3
Original file line number
Diff line number
Diff line change
@@ -28,10 +28,51 @@ gulp.src('file.js')
28
28
```javascript
29
29
gulp.src('file.js')
30
30
.pipe(javascriptObfuscator({
31
-
compact:true,
32
-
sourceMap:true
31
+
compact:true
33
32
}))
34
33
.pipe(gulp.dest('dist'));
35
34
```
36
35
37
-
Using **sourceMap** option with value set to **true** will also output a _.map_ file to Gulp stream.
36
+
The only exception is obfuscator's `sourceMap` option which must not be set, as it will be handled automatically when using `gulp-sourcemaps`.
37
+
38
+
## Source Maps
39
+
40
+
With version `1.1.6` onwards, gulp-javascript-obfuscator can be used in tandem with [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps) in order to generate source maps for your javascript files.
41
+
42
+
You will need to initialize gulp-sourcemaps prior to running gulp-javascript-obfuscator and write the source maps after, as such:
43
+
44
+
```javascript
45
+
constsourcemaps=require('gulp-sourcemaps');
46
+
47
+
gulp.src('file.js')
48
+
.pipe(sourcemaps.init())
49
+
.pipe(javascriptObfuscator({
50
+
compact:true
51
+
}))
52
+
.pipe(sourcemaps.write())
53
+
.pipe(gulp.dest('dist'));
54
+
```
55
+
56
+
This will output a `file.js.map` file to the **dist** directory.
57
+
58
+
You can chain other gulp plugins as well:
59
+
60
+
```javascript
61
+
constsourcemaps=require('gulp-sourcemaps');
62
+
63
+
gulp.src('file.js')
64
+
.pipe(sourcemaps.init())
65
+
// use babel to pre-process javascript files
66
+
.pipe(babel({
67
+
presets: ['@babel/preset-env']
68
+
}))
69
+
.pipe(javascriptObfuscator({
70
+
compact:true
71
+
}))
72
+
.pipe(sourcemaps.write())
73
+
.pipe(gulp.dest('dist'));
74
+
```
75
+
76
+
### Alternative source maps method
77
+
78
+
For backwards compatibility, if `gulp-sourcemaps` is not used and obfuscator's **sourceMap** option is set to **true**, a _.map_ file will be thrown to Gulp stream. ([This method is _deprecated_ and not recommended for future use.](https://github.com/javascript-obfuscator/gulp-javascript-obfuscator/pull/18#backwards-compatibility))
0 commit comments