Learn AST and create babel plugin.
Generate hash ID by given an input.
$ npm install --save-dev babel-plugin-inline-hash-id
{
"plugins": [
"inline-hash-id"
]
}
{
"plugins": [
["inline-hash-id", {
"fnName": "__hashId",
"algorithm": "sha256",
"digest": "base64",
"maxLength": 12,
"uniqPerFile": true
}]
]
}
React.createElement('div', {
id: __hashId('root')
});
React.createElement('div', {
id: 'BkbudHtGGjOI'
});
See the example
for more details.
MIT © Guntur Poetra