mixed-typed property names (some with delimiters)
yairEO opened this issue · 2 comments
yairEO commented
How can I do mixed replace? (some variables have delimiters and some don't:
replace({
"delimiters" : [ '[', ']' ],
"SERVERPATH" : JSON.stringify(config.serverPath), // <---- requires delimiters
"prodUrl" : JSON.stringify(config.prodUrl), // <---- requires delimiters
"mocks/" : JSON.stringify(config.serverPath + '/mocks/')
})
It was an utter failure to not use the delimiters
key and trying to manually write [SERVERPATH]
as key name. I also tried to escape the key like \[SERVERPATH\]
without output success .
mrkishi commented
It's not possible without patching rollup-plugin-replace
.
I submitted a PR that fixes this, but it hasn't been merged. Until then, I'm using that branch as a dependency instead of the published npm package.
Rich-Harris commented
Special characters are now supported in keys thanks to @mrkishi, so I'll close this. An alternative solution would be just to have two plugin instances — one with delimiters, one without.