Skip to content

Commit

Permalink
feature: add support for large files
Browse files Browse the repository at this point in the history
- expose option to handle large files via options.largeFiles
- add conditional to not remove comments from large files
- update readme with largeFile info
  • Loading branch information
sambou committed Apr 27, 2016
1 parent f0acd2a commit 04127c9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,27 @@ gulp.task('javascript', function() {
});
```

#### Handle large files

To handle large files, pass the option `largeFile: true` to `sourcemaps.init()`.

Example:
```javascript
var gulp = require('gulp');
var plugin1 = require('gulp-plugin1');
var plugin2 = require('gulp-plugin2');
var sourcemaps = require('gulp-sourcemaps');

gulp.task('javascript', function() {
gulp.src('src/**/*.js')
.pipe(sourcemaps.init({largeFile: true}))
.pipe(plugin1())
.pipe(plugin2())
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist'));
});
```

#### Handle source files from different directories

Use the `base` option on `gulp.src` to make sure all files are relative to a common base directory.
Expand Down
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ module.exports.init = function init(options) {
var sourcePath = ''; //root path for the sources in the map

// Try to read inline source map
sourceMap = convert.fromSource(fileContent);
sourceMap = convert.fromSource(fileContent, options.largeFile);
if (sourceMap) {
sourceMap = sourceMap.toObject();
// sources in map are relative to the source file
sourcePath = path.dirname(file.path);
fileContent = convert.removeComments(fileContent);
if (!options.largeFile) {
fileContent = convert.removeComments(fileContent);
}
} else {
// look for source map comment referencing a source map file
var mapComment = convert.mapFileCommentRegex.exec(fileContent);
Expand Down

0 comments on commit 04127c9

Please sign in to comment.