sourcemap-filename
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]
pattern
If the module is called without '.map' is appended to sourceFile
.
pattern
If the module is called with 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'
- example: for 'beep/boop.js',
-
$2
: the file extension without the leading dot- example: for 'beep/boop.js',
$2
references 'js'
- example: for 'beep/boop.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