npm package: @jsdevtools/sourcemapify
Description: Source Map plugin for Browserify
Author: James Messinger
Latest version: 2.0.2

Sourcemapify
============================
#### source-map plugin for Browserify

[![Cross-Platform Compatibility](https://jstools.dev/img/badges/os-badges.svg)](https://github.com/JS-DevTools/sourcemapify/actions)
[![Build Status](https://github.com/JS-DevTools/sourcemapify/workflows/CI-CD/badge.svg)](https://github.com/JS-DevTools/sourcemapify/actions)

[![Coverage Status](https://coveralls.io/repos/github/JS-DevTools/sourcemapify/badge.svg?branch=master)](https://coveralls.io/github/JS-DevTools/sourcemapify?branch=master)
[![Dependencies](https://david-dm.org/JS-DevTools/sourcemapify.svg)](https://david-dm.org/JS-DevTools/sourcemapify)

[![npm](https://img.shields.io/npm/v/@jsdevtools/sourcemapify.svg)](https://www.npmjs.com/package/@jsdevtools/sourcemapify)
[![License](https://img.shields.io/npm/l/@jsdevtools/sourcemapify.svg)](LICENSE)
[![Buy us a tree](https://img.shields.io/badge/Treeware-%F0%9F%8C%B3-lightgreen)](https://plant.treeware.earth/JS-DevTools/sourcemapify)


The default sourcemap that Browserify generates uses paths that are relative to the current directory, which may not always be what you want. This plugin lets you change the relative path, or use absolute paths.

This plugin was inspired by [browserify-sourcemap-root-transform](https://github.com/blackberry/browserify-sourcemap-root-transform), so check that one out if this one doesn't meet your needs.



Related Projects
--------------------------
- [simplifyify](https://jstools.dev/simplifyify)<br>
  A simplified Browserify and Watchify CLI

- [globify](https://jstools.dev/globify)<br>
  Run browserify and watchify with globs - even on Windows

- [browserify-banner](https://jstools.dev/browserify-banner)<br>
  Add a comment (and/or code) to the top of your Browserify bundle



Installation
--------------------------
Install using [npm](https://docs.npmjs.com/about-npm/):

```bash
npm install @jsdevtools/sourcemapify
```


Usage
--------------------------
### Command Line
Use Browserify's sub-argument command-line syntax, like this:

```bash
browserify -p [ @jsdevtools/sourcemapify --root "../../" ] --debug
```

### Browserify API
Use the plugin programmatically like this:  [full example](test/api.js)

```javascript
var browserify = require('browserify');
var sourcemapify = require('@jsdevtools/sourcemapify');

browserify({debug: true})
  .plugin(sourcemapify, {base: 'www/js'})
  .bundle()
  .pipe(fs.createWriteStream('www/js/bundle.js', 'utf8'));
```


Options
--------------------------
The following options can be set via the API or command-line:

#### `root` (string)
The root path for all files in the source map. It can be an absolute or relative path. This string will be prepended as-is to each file path.

#### `base` (string)
The base path of the bundle (i.e. the bundle file's directory, relative to cwd). This path will be used to determine the relative path of each file. It can be an absolute or relative path.



Contributing
--------------------------
Contributions, enhancements, and bug-fixes are welcome!  [Open an issue](https://github.com/JS-DevTools/sourcemapify/issues) on GitHub and [submit a pull request](https://github.com/JS-DevTools/sourcemapify/pulls).

#### Building
To build the project locally on your computer:

1. __Clone this repo__<br>
`git clone https://github.com/JS-DevTools/sourcemapify.git`

2. __Install dependencies__<br>
`npm install`

3. __Link the module to itself__ (so Browserify can find the plugin)<br>
`npm link`<br>
`npm link @jsdevtools/sourcemapify`

4. __Run the tests__<br>
`npm test`



License
--------------------------
Sourcemapify is 100% free and open-source, under the [MIT license](LICENSE). Use it however you want.

This package is [Treeware](http://treeware.earth). If you use it in production, then we ask that you [**buy the world a tree**](https://plant.treeware.earth/JS-DevTools/sourcemapify) to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.



Big Thanks To
--------------------------
Thanks to these awesome companies for their support of Open Source developers ❤

[![Travis CI](https://jstools.dev/img/badges/travis-ci.svg)](https://travis-ci.com)
[![SauceLabs](https://jstools.dev/img/badges/sauce-labs.svg)](https://saucelabs.com)
[![Coveralls](https://jstools.dev/img/badges/coveralls.svg)](https://coveralls.io)