broccoli-source-map
Advanced tools
Comparing version 0.1.1 to 0.1.2
20
index.js
@@ -15,3 +15,3 @@ 'use strict'; | ||
return process(relativePath); | ||
}; | ||
} | ||
} | ||
@@ -21,4 +21,4 @@ } | ||
function _isSourceMappableFile(path) { | ||
return relativePath.slice(-3) === '.js' | ||
|| relativePath.slice(-4) === '.css'; | ||
return path.slice(-3) === '.js' | ||
|| path.slice(-4) === '.css'; | ||
} | ||
@@ -39,3 +39,3 @@ | ||
var smap = convert.fromMapFileSource(srcCode, srcDir); | ||
if (smap !== null) { | ||
if (smap !== null && typeof smap['sourcemap'] !== 'undefined') { | ||
if (typeof smap.getProperty('sourcesContent') === 'undefined' && typeof smap.getProperty('sources') !== 'undefined') { | ||
@@ -47,3 +47,7 @@ var contents = smap.getProperty('sources').map(function(spath) { | ||
} | ||
fs.writeFileSync(destPath, convert.removeMapFileComments(srcCode) + '\n' + smap.toComment()); | ||
var comment = smap.toComment(); | ||
if (destPath.slice(-4) === '.css') { | ||
comment = comment.replace(/^\/\//, '/*') + ' */'; | ||
} | ||
fs.writeFileSync(destPath, convert.removeMapFileComments(srcCode) + '\n' + comment); | ||
} else { | ||
@@ -70,3 +74,7 @@ fs.writeFileSync(destPath, srcCode); | ||
if (smap !== null) { | ||
fs.writeFileSync(destPath, convert.removeComments(srcCode) + '\n//# sourceMappingURL=' + relativePath + '.map'); | ||
var comment = '//# sourceMappingURL=' + relativePath + '.map'; | ||
if (destPath.slice(-4) === '.css') { | ||
comment = '/*# sourceMappingURL=' + relativePath + '.map */'; | ||
} | ||
fs.writeFileSync(destPath, convert.removeComments(srcCode) + '\n' + comment); | ||
fs.writeFileSync(destPath + '.map', smap.toJSON()); | ||
@@ -73,0 +81,0 @@ } else { |
{ | ||
"name": "broccoli-source-map", | ||
"description": "A Broccoli plugin for inlining or extracting sourcemaps", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"author": "Greg V <floatboth@me.com>", | ||
@@ -6,0 +6,0 @@ "engines": { |
@@ -1,2 +0,2 @@ | ||
# broccoli-source-map [![npm version](https://img.shields.io/npm/v/broccoli-source-map.svg?style=flat)](https://www.npmjs.org/package/broccoli-source-map) [![npm downloads](https://img.shields.io/npm/dm/broccoli-source-map.svg?style=flat)](https://www.npmjs.org/package/broccoli-source-map) [![WTFPL](https://img.shields.io/badge/license-WTFPL-brightgreen.svg?style=flat)](https://www.tldrlegal.com/l/wtfpl) | ||
# broccoli-source-map [![npm version](https://img.shields.io/npm/v/broccoli-source-map.svg?style=flat)](https://www.npmjs.org/package/broccoli-source-map) [![npm downloads](https://img.shields.io/npm/dm/broccoli-source-map.svg?style=flat)](https://www.npmjs.org/package/broccoli-source-map) [![Dependency Status](https://img.shields.io/gemnasium/myfreeweb/broccoli-source-map.svg?style=flat)](https://gemnasium.com/myfreeweb/broccoli-source-map) [![WTFPL](https://img.shields.io/badge/license-WTFPL-brightgreen.svg?style=flat)](https://www.tldrlegal.com/l/wtfpl) | ||
@@ -3,0 +3,0 @@ A [Broccoli] plugin for inlining or extracting [JavaScript source maps] using [convert-source-map]. |
6684
81