package.json 9.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. {
  2. "name": "gulp-sourcemaps",
  3. "version": "1.3.0",
  4. "description": "Source map support for Gulp.js",
  5. "homepage": "http://github.com/floridoo/gulp-sourcemaps",
  6. "repository": {
  7. "type": "git",
  8. "url": "git://github.com/floridoo/gulp-sourcemaps.git"
  9. },
  10. "main": "index.js",
  11. "scripts": {
  12. "test": "jshint *.js test/*.js && faucet test/*.js",
  13. "tap": "node node_modules/argg test/*.js",
  14. "cover": "istanbul cover --dir reports/coverage node_modules/argg test/*.js",
  15. "coveralls": "istanbul cover node_modules/argg test/*.js --report lcovonly && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage"
  16. },
  17. "keywords": [
  18. "gulpplugin",
  19. "gulp",
  20. "source maps",
  21. "sourcemaps"
  22. ],
  23. "author": {
  24. "name": "Florian Reiterer",
  25. "email": "[email protected]"
  26. },
  27. "license": "ISC",
  28. "dependencies": {
  29. "through2": "^0.6.1",
  30. "vinyl": "^0.4.2",
  31. "convert-source-map": "^0.4.1"
  32. },
  33. "devDependencies": {
  34. "jshint": "^2.5.2",
  35. "tape": "^2.13.3",
  36. "argg": "0.0.1",
  37. "istanbul": "^0.3.0",
  38. "faucet": "0.0.1",
  39. "coveralls": "^2.11.1"
  40. },
  41. "readme": "## gulp-sourcemaps [![NPM version][npm-image]][npm-url] [![build status][travis-image]][travis-url] [![Test coverage][coveralls-image]][coveralls-url]\n\n### Usage\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\ngulp.task('javascript', function() {\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\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/floridoo/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\ngulp.task('javascript', function() {\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```\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\ngulp.task('javascript', function() {\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```\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\ngulp.task('javascript', function() {\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```\n\n\n\n### Init Options\n\n- `loadMaps`\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- `debug`\n Set this to `true` to output debug messages (e.g. about missing source content).\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 gulp.task('javascript', function() {\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\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 path where the source files are hosted (use this when `includeContent` is set to `false`). This is an URL (or subpath) relative to the source map, not a local file system path. If you have sources in different subpaths, an absolute path (from the domain root) pointing to the source file root is recommended, or define it with a function.\n\n Example:\n ```javascript\n gulp.task('javascript', function() {\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\n Example (using a function):\n ```javascript\n gulp.task('javascript', function() {\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\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 gulp.task('javascript', function() {\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\n Example (using a function):\n ```javascript\n gulp.task('javascript', function() {\n var stream = gulp.src('src/**/*.js')\n .pipe(sourcemaps.init())\n .pipe(plugin1())\n .pipe(plugin2())\n .pipe(sourcemaps.write('../maps', {\n sourceMappingURLPrefix: function(file) {\n return 'https://asset-host.example.com/assets'\n }\n }))\n .pipe(gulp.dest('public/scripts'));\n });\n ```\n\n This will result in source mapping URL comment like `sourceMappingURL=https://asset-host.example.com/assets/maps/helloworld.js.map`.\n\n- `debug`\n\n Set this to `true` to output debug messages (e.g. about missing source content).\n\n### Plugin developers only: 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/floridoo/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/floridoo/gulp-sourcemaps/wiki/Plugins-with-gulp-sourcemaps-support)\n\n#### Example:\n\n```javascript\nvar through = require('through2');\nvar applySourceMap = require('vinyl-sourcemaps-apply');\nvar myTransform = require('myTransform');\n\nmodule.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[npm-image]: https://img.shields.io/npm/v/gulp-sourcemaps.svg?style=flat\n[npm-url]: https://npmjs.org/package/gulp-sourcemaps\n[travis-image]: https://img.shields.io/travis/floridoo/gulp-sourcemaps.svg?style=flat\n[travis-url]: https://travis-ci.org/floridoo/gulp-sourcemaps\n[coveralls-image]: https://img.shields.io/coveralls/floridoo/gulp-sourcemaps.svg?style=flat\n[coveralls-url]: https://coveralls.io/r/floridoo/gulp-sourcemaps?branch=master\n",
  42. "readmeFilename": "README.md",
  43. "bugs": {
  44. "url": "https://github.com/floridoo/gulp-sourcemaps/issues"
  45. },
  46. "_id": "[email protected]",
  47. "dist": {
  48. "shasum": "f8f72759fc8b1ec68c37365b4714ce239242d054"
  49. },
  50. "_from": "gulp-sourcemaps@",
  51. "_resolved": "https://registry.npmjs.org/gulp-sourcemaps/-/gulp-sourcemaps-1.3.0.tgz"
  52. }