{"name":"gulp-sourcemaps","version":"2.0.0-alpha","description":"Source map support for Gulp.js","homepage":"http://github.com/floridoo/gulp-sourcemaps","repository":{"type":"git","url":"git://github.com/floridoo/gulp-sourcemaps.git"},"main":"index.js","scripts":{"test":"jshint *.js test/*.js && faucet test/*.js","tap":"tape test/*.js","cover":"istanbul cover --dir reports/coverage tape \"test/*.js\"","coveralls":"istanbul cover tape \"test/*.js\" --report lcovonly && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage"},"keywords":["gulpplugin","gulp","source maps","sourcemaps"],"author":{"name":"Florian Reiterer","email":"me@florianreiterer.com"},"license":"ISC","dependencies":{"acorn":"^2.6.4","convert-source-map":"^1.1.1","css":"^2.2.1","detect-newline":"^1.0.3","graceful-fs":"^4.1.2","source-map":"^0.5.3","strip-bom":"^2.0.0","through2":"^2.0.0","vinyl":"^1.0.0"},"devDependencies":{"jshint":"^2.8.0","tape":"^4.2.0","istanbul":"^0.3.21","faucet":"0.0.1","coveralls":"^2.11.4"},"files":["index.js","package.json","README.md","LICENSE.md"],"gitHead":"f0acd2a31150b0403c14eed53e6234b192704257","bugs":{"url":"https://github.com/floridoo/gulp-sourcemaps/issues"},"_id":"gulp-sourcemaps@2.0.0-alpha","_shasum":"f0c7bc0e67ed3f0a0f669562c80a04664a23dadf","_from":".","_npmVersion":"3.6.0","_nodeVersion":"5.6.0","_npmUser":{"name":"floridoo","email":"florian.reiterer@gmail.com"},"maintainers":[{"name":"floridoo","email":"florian.reiterer@gmail.com"}],"dist":{"shasum":"f0c7bc0e67ed3f0a0f669562c80a04664a23dadf","tarball":"http://registry-npm.ywwl.com/gulp-sourcemaps/download/gulp-sourcemaps-2.0.0-alpha.tgz","integrity":"sha512-O3rHa24wa8mc3N5O4A01KAEWECXjhonp/V6RLUVLOvmT3zENbF/UMr+kaop4BnnwGFxKGuodKRiiZqvHfbqT1w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAhDpIGzrmDwRFNY8rZhIVJ6DM06E2tvrxG7scwGlCBuAiEAtG7iYy+EdA3mX7qSnAxRqPOlVFPESd0FrgunS7G2txI="}],"size":6675,"noattachment":false,"key":"/gulp-sourcemaps/-/gulp-sourcemaps-2.0.0-alpha.tgz"},"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/gulp-sourcemaps-2.0.0-alpha.tgz_1461091131653_0.3964899682905525"},"directories":{},"readme":"# gulp-sourcemaps\n\n[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Travis Build Status][travis-image]][travis-url] [![AppVeyor Build Status][appveyor-image]][appveyor-url] [![Coveralls Status][coveralls-image]][coveralls-url]\n\nSourcemap support for gulpjs.\n\n### Usage\n\nAll 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).\n\n#### Write inline source maps\nInline source maps are embedded in the source file.\n\nExample:\n```javascript\nvar gulp = require('gulp');\nvar plugin1 = require('gulp-plugin1');\nvar plugin2 = require('gulp-plugin2');\nvar sourcemaps = require('gulp-sourcemaps');\n\nfunction javascript() {\n  gulp.src('src/**/*.js')\n    .pipe(sourcemaps.init())\n      .pipe(plugin1())\n      .pipe(plugin2())\n    .pipe(sourcemaps.write())\n    .pipe(gulp.dest('dist'));\n};\n\n\nexports.javascript = javascript;\n```\n\nAll 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).\n\n\n#### Write external source map files\n\nTo write external source map files, pass a path relative to the destination to `sourcemaps.write()`.\n\nExample:\n```javascript\nvar gulp = require('gulp');\nvar plugin1 = require('gulp-plugin1');\nvar plugin2 = require('gulp-plugin2');\nvar sourcemaps = require('gulp-sourcemaps');\n\nfunction javascript() {\n  gulp.src('src/**/*.js')\n    .pipe(sourcemaps.init())\n      .pipe(plugin1())\n      .pipe(plugin2())\n    .pipe(sourcemaps.write('../maps'))\n    .pipe(gulp.dest('dist'));\n};\n\nexports.javascript = javascript;\n```\n\n#### Load existing source maps\n\nTo load existing source maps, pass the option `loadMaps: true` to `sourcemaps.init()`.\n\nExample:\n```javascript\nvar gulp = require('gulp');\nvar plugin1 = require('gulp-plugin1');\nvar plugin2 = require('gulp-plugin2');\nvar sourcemaps = require('gulp-sourcemaps');\n\nfunction javascript() {\n  gulp.src('src/**/*.js')\n    .pipe(sourcemaps.init({loadMaps: true}))\n      .pipe(plugin1())\n      .pipe(plugin2())\n    .pipe(sourcemaps.write())\n    .pipe(gulp.dest('dist'));\n};\n\nexports.javascript = javascript;\n```\n\n#### Handle large files\n\nTo handle large files, pass the option `largeFile: true` to `sourcemaps.init()`.\n\nExample:\n```javascript\nvar gulp = require('gulp');\nvar plugin1 = require('gulp-plugin1');\nvar plugin2 = require('gulp-plugin2');\nvar sourcemaps = require('gulp-sourcemaps');\n\nfunction javascript() {\n  gulp.src('src/**/*.js')\n    .pipe(sourcemaps.init({largeFile: true}))\n      .pipe(plugin1())\n      .pipe(plugin2())\n    .pipe(sourcemaps.write())\n    .pipe(gulp.dest('dist'));\n};\n\nexports.javascript = javascript;\n```\n\n#### Handle source files from different directories\n\nUse the `base` option on `gulp.src` to make sure all files are relative to a common base directory.\n\nExample:\n```javascript\nvar gulp = require('gulp');\nvar plugin1 = require('gulp-plugin1');\nvar plugin2 = require('gulp-plugin2');\nvar sourcemaps = require('gulp-sourcemaps');\n\nfunction javascript() {\ngulp.src(['src/test.js', 'src/testdir/test2.js'], { base: 'src' })\n    .pipe(sourcemaps.init())\n      .pipe(plugin1())\n      .pipe(plugin2())\n    .pipe(sourcemaps.write('../maps'))\n    .pipe(gulp.dest('dist'));\n};\n\nexports.javascript = javascript;\n```\n\n#### Alter `sources` property on sourcemaps\n\nThe exported `mapSources` method gives full control over the source paths. It takes a function that is called for every source and receives the default source path as a parameter and the original vinyl file.\n\nExample:\n```javascript\nfunction javascript() {\n  var stream = gulp.src('src/**/*.js')\n    .pipe(sourcemaps.init())\n      .pipe(plugin1())\n      .pipe(plugin2())\n      // be careful with the sources returned otherwise contents might not be loaded properly\n      .pipe(sourcemaps.mapSources(function(sourcePath, file) {\n        // source paths are prefixed with '../src/'\n        return '../src/' + sourcePath;\n      }))\n    .pipe(sourcemaps.write('../maps')\n    .pipe(gulp.dest('public/scripts'));\n};\n\nexports.javascript = javascript;\n```\n\n#### Generate Identity Sourcemap\n\nThe exported `identityMap` method allows you to generate a full valid source map encoding no changes (slower, only for Javascript and CSS) instead of the default empty source map (no mappings, fast). __Use this option if you get missing or incorrect mappings, e.g. when debugging.__\n\nExample:\n```javascript\nfunction javascript() {\n  var stream = gulp.src('src/**/*.js')\n    .pipe(sourcemaps.init())\n      // An identity sourcemap will be generated at this step\n      .pipe(sourcemaps.identityMap())\n      .pipe(plugin1())\n      .pipe(plugin2())\n    .pipe(sourcemaps.write('../maps')\n    .pipe(gulp.dest('public/scripts'));\n};\n\nexports.javascript = javascript;\n```\n\n\n### Init Options\n\n- `loadMaps`\n\n  Set to true to load existing maps for source files. Supports the following:\n    - inline source maps\n    - source map files referenced by a `sourceMappingURL=` comment\n    - source map files with the same name (plus .map) in the same directory\n\n\n- `identityMap`\n\n  __This option is deprecated. Upgrade to use our [`sourcemap.identityMap`](#generate-identity-sourcemap) API.__\n\n\n### Write Options\n\n- `addComment`\n\n  By default a comment containing / referencing the source map is added. Set this to `false` to disable the comment (e.g. if you want to load the source maps by header).\n\n  Example:\n  ```javascript\n  function javascript() {\n    var stream = gulp.src('src/**/*.js')\n      .pipe(sourcemaps.init())\n        .pipe(plugin1())\n        .pipe(plugin2())\n      .pipe(sourcemaps.write('../maps', {addComment: false}))\n      .pipe(gulp.dest('dist'));\n  };\n\n  exports.javascript = javascript;\n  ```\n\n- `includeContent`\n\n  By default the source maps include the source code. Pass `false` to use the original files.\n\n  Including the content is the recommended way, because it \"just works\". When setting this to `false` you have to host the source files and set the correct `sourceRoot`.\n\n- `sourceRoot`\n\n  Set the location where the source files are hosted (use this when `includeContent` is set to `false`). This is usually a URL (or an absolute URL path), not a local file system path.\n  By default the source root is '' or in case `destPath` is set, the relative path from the source map to the source base directory (this should work for many dev environments).\n  If a relative path is used (empty string or one starting with a `.`), it is interpreted as a path relative to the destination. The plugin rewrites it to a path relative to each source map.\n\n  Example:\n  ```javascript\n  function javascript() {\n    var stream = gulp.src('src/**/*.js')\n      .pipe(sourcemaps.init())\n        .pipe(plugin1())\n        .pipe(plugin2())\n      .pipe(sourcemaps.write({includeContent: false, sourceRoot: '/src'}))\n      .pipe(gulp.dest('dist'));\n  };\n\n  exports.javascript = javascript;\n  ```\n\n  Example (using a function):\n  ```javascript\n  function javascript() {\n    var stream = gulp.src('src/**/*.js')\n      .pipe(sourcemaps.init())\n        .pipe(plugin1())\n        .pipe(plugin2())\n      .pipe(sourcemaps.write({\n        includeContent: false,\n        sourceRoot: function(file) {\n          return '/src';\n        }\n       }))\n      .pipe(gulp.dest('dist'));\n  };\n\n  exports.javascript = javascript;\n  ```\n\n  Example (relative path):\n  ```javascript\n  function javascript() {\n    var stream = gulp.src('src/**/*.js')\n      .pipe(sourcemaps.init())\n        .pipe(plugin1())\n        .pipe(plugin2())\n      .pipe(sourcemaps.write('.', {includeContent: false, sourceRoot: '../src'}))\n      .pipe(gulp.dest('dist'));\n  };\n\n  exports.javascript = javascript;\n  ```\n  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`).\n\n- `destPath`\n\n  Set the destination path (the same you pass to `gulp.dest()`). If the source map destination path is not a sub path of the destination path, this is needed to get the correct path in the `file` property of the source map.\n  In addition, it allows to automatically set a relative `sourceRoot` if none is set explicitly.\n\n- `sourceMappingURLPrefix`\n\n  Specify a prefix to be prepended onto the source map URL when writing external source maps. Relative paths will have their leading dots stripped.\n\n  Example:\n  ```javascript\n  function javascript() {\n    var stream = gulp.src('src/**/*.js')\n      .pipe(sourcemaps.init())\n        .pipe(plugin1())\n        .pipe(plugin2())\n      .pipe(sourcemaps.write('../maps', {\n        sourceMappingURLPrefix: 'https://asset-host.example.com/assets'\n      }))\n      .pipe(gulp.dest('public/scripts'));\n  };\n\n  exports.javascript = javascript;\n  ```\n\n  This will result in a source mapping URL comment like `sourceMappingURL=https://asset-host.example.com/assets/maps/helloworld.js.map`.\n\n- `sourceMappingURL`\n\n  If you need full control over the source map URL you can pass a function to this option. The output of the function must be the full URL to the source map (in function of the output file).\n\n  Example:\n  ```javascript\n  function javascript() {\n    var stream = gulp.src('src/**/*.js')\n      .pipe(sourcemaps.init())\n        .pipe(plugin1())\n        .pipe(plugin2())\n      .pipe(sourcemaps.write('../maps', {\n        sourceMappingURL: function(file) {\n          return 'https://asset-host.example.com/' + file.relative + '.map';\n        }\n      }))\n      .pipe(gulp.dest('public/scripts'));\n  };\n\n  exports.javascript = javascript;\n  ```\n\n  This will result in a source mapping URL comment like `sourceMappingURL=https://asset-host.example.com/helloworld.js.map`.\n\n- `mapFile`\n\n  This option allows to rename the map file. It takes a function that is called for every map and receives the default map path as a parameter.\n\n  Example:\n  ```javascript\n  function javascript() {\n    var stream = gulp.src('src/**/*.js')\n      .pipe(sourcemaps.init())\n        .pipe(plugin1())\n        .pipe(plugin2())\n      .pipe(sourcemaps.write('../maps', {\n        mapFile: function(mapFilePath) {\n          // source map files are named *.map instead of *.js.map\n          return mapFilePath.replace('.js.map', '.map');\n        }\n      }))\n      .pipe(gulp.dest('public/scripts'));\n  };\n\n  exports.javascript = javascript;\n  ```\n\n- `mapSources`\n\n  __This option is deprecated. Upgrade to use our [`sourcemap.mapSources`](#alter-sources-property-on-sourcemaps) API.__\n\n- `charset`\n\n  Sets the charset for inline source maps. Default: `utf8`\n\n- `clone`\n\n  Clones the original file for creation of the map file. Could be important if file history is important. See [file.clone()](https://github.com/gulpjs/vinyl#filecloneoptions) for possible options. Default: `{deep:false, contents:false}`\n\n### Plugin developers only:\n\n- **How to add source map support to plugins**\n\n  - Generate a source map for the transformation the plugin is applying\n  - **Important**: Make sure the paths in the generated source map (`file` and `sources`) are relative to `file.base` (e.g. use `file.relative`).\n  - Apply this source map to the vinyl `file`. E.g. by using [vinyl-sourcemaps-apply](https://github.com/gulp-sourcemaps/vinyl-sourcemaps-apply).\n    This combines the source map of this plugin with the source maps coming from plugins further up the chain.\n  - Add your plugin to the [wiki page](https://github.com/gulp-sourcemaps/gulp-sourcemaps/wiki/Plugins-with-gulp-sourcemaps-support)\n\n  #### Example:\n\n  ```js\n  var through = require('through2');\n  var applySourceMap = require('vinyl-sourcemaps-apply');\n  var myTransform = require('myTransform');\n\n  module.exports = function(options) {\n\n    function transform(file, encoding, callback) {\n      // generate source maps if plugin source-map present\n      if (file.sourceMap) {\n        options.makeSourceMaps = true;\n      }\n\n      // do normal plugin logic\n      var result = myTransform(file.contents, options);\n      file.contents = new Buffer(result.code);\n\n      // apply source map to the chain\n      if (file.sourceMap) {\n        applySourceMap(file, result.map);\n      }\n\n      this.push(file);\n      callback();\n    }\n\n    return through.obj(transform);\n  };\n  ```\n\n  - **Verify sourcemaps are working**\n\n    See example below or refer to [test/write.js](./test/write.js)\n\n  #### Example:\n  ```js\n  var stream = plugin();\n  var init = sourcemaps.init();\n  var write = sourcemaps.write();\n\n  init.pipe(stream).pipe(write);\n\n  write.on('data', function (file) {\n    assert(...);\n    cb();\n  });\n\n  init.write(new gutil.File(...));\n  init.end();\n  ```\n\n### Debugging\n\nAll debugging output relies on [visionmedia/debug](https://github.com/visionmedia/debug). Follow the directions to set the\nenvironment variable `$DEBUG`.\n\nFor a few examples of debug you could use:\n\n```sh\n  DEBUG='gulp-sourcemaps:*' #everything\n  DEBUG='gulp-sourcemaps:init' #init/index.js\n  DEBUG='gulp-sourcemaps:init:*' #init/index.internals.js\n  DEBUG='gulp-sourcemaps:write:' #write/index.js\n  DEBUG='gulp-sourcemaps:write:*' #write/index.internals.js\n  DEBUG='gulp-sourcemaps:write:,gulp-sourcemaps:init:**' #write/index.internals.js and init/index.internals.js\n```\n\n[downloads-image]: http://img.shields.io/npm/dm/gulp-sourcemaps.svg\n[npm-url]: https://www.npmjs.com/package/gulp-sourcemaps\n[npm-image]: http://img.shields.io/npm/v/gulp-sourcemaps.svg\n\n[travis-url]: https://travis-ci.org/gulp-sourcemaps/gulp-sourcemaps\n[travis-image]: http://img.shields.io/travis/gulp-sourcemaps/gulp-sourcemaps.svg?label=travis-ci\n\n[appveyor-url]: https://ci.appveyor.com/project/phated/gulp-sourcemaps\n[appveyor-image]: https://img.shields.io/appveyor/ci/phated/gulp-sourcemaps.svg?label=appveyor\n\n[coveralls-url]: https://coveralls.io/r/gulp-sourcemaps/gulp-sourcemaps\n[coveralls-image]: http://img.shields.io/coveralls/gulp-sourcemaps/gulp-sourcemaps/master.svg\n","publish_time":1461091133078,"_cnpm_publish_time":1461091133078,"dist-tags":{"latest":"3.0.0","legacy":"1.12.1"}}