0.0.5 • Published 9 years ago

sourcemap-filename v0.0.5

Weekly downloads
4
License
MIT
Repository
github
Last release
9 years ago

sourcemap-filename Build Status

The convention for sourcemap file names is to simply append '.map' to the entire file name. Unfortunately some CMSs don't support multiple extensions (I'm looking at you, Magnolia), so occasionally one needs something more flexible.

Installation

npm install sourcemap-filename

API

The module exports a function that has two parameters:

  • {string} sourceFile
  • {string} [pattern]

If the module is called without pattern

'.map' is appended to sourceFile.

If the module is called with pattern

The entire base file name of sourceFile is replaced by pattern. pattern supports two backreferences:

  • $1: the base file name without extension
    • example: for 'beep/boop.js', $1 references 'boop'
  • $2: the file extension without the leading dot
    • example: for 'beep/boop.js', $2 references 'js'

Usage

var sourcemapFilename = require('sourcemap-filename');
var sourceFile = 'beep.js';
var mapFile = sourcemapFilename(sourceFile); // beep.js.map
var pattern = '$1-$2_map.json';
mapFile = sourcemapFilename(sourceFile, pattern); // beep-js_map.json

License

MIT