babel-plugin-hash-strings
Replace all instances of
"@@strings like this"
with hashes.
This might be useful for decreasing the size of your JavaScript bundles. But note that gzip might actually be better for your code because hashes do not compress well.
Install
npm install --save-dev babel-plugin-hash-strings
Usage
It's recommended that you only use this plugin in a production build.
// babel.config.jslet presets = ... let plugins = ... if processenvNODE_ENV === "production" plugins moduleexports = presets plugins
Example
Input:
let value = "@@hash me"
Output:
let value = "5953c"
options.chars
This plugin defaults to really short hashes because you probably won't have
that many strings that uniqueness matters all that much. But just in case you
do have a duplicate, the plugin has a built-in check for them and you can
increase the length of your strings using options.chars
// babel.config.jslet presets = ... let plugins = ... if processenvNODE_ENV === "production" plugins moduleexports = presets plugins