I'm trying to convert a js config to string, but i'm having a problem with the imported values.
Please check the desired output below.
Codesandbox Example
This is a follow-up question to this: Refactoring javascript string config
import { TEST } from "./config";
export default function App() {
let configString = (() => {
var configOptions = {
message: TEST.Success
};
}).toString();
configString = configString.slice(
configString.indexOf("{") + 1,
configString.lastIndexOf("}")
);
return <p>{configString}</p>;
}
OUTPUT:
var configOptions = { message: _config.TEST.Success };
DESIRED OUTPUT:
var configOptions = { message: Success };