Reputation: 4693
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?
Upvotes: 2
Views: 376
Reputation: 4404
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
Upvotes: 2