Frage

I need to replace a String someString by another anotherString in my JS files, e.g.

function someString() { ... }

should become

function anotherString() { ... }

in brunch (can be pre- or post-compilation, however I would like to avoid copying all files to a temporary location).

Running this in onCompile works, however it seems to break sourceMaps (because the Strings are not the same length).

Is there a sourceMap-safe way to do this?

War es hilfreich?

Lösung

I had the exact same question and wrote this little script:

https://www.npmjs.org/package/sourcemap-aware-replace

usage:

sourcemap-aware-replace --search=foo --replace=barr --in-map=test.js.map --out-file=test.replaced.js
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top