Add server data to index.html

Viewed 1161

I have a simple app build with Create React App. I'd like to inject some server data in a jinja template. Obviously local webpack server can't parse jinja

<script type="text/javascript">
    window.SERVER_DATA = {
      "company": {{ company|dumps|escapejson }}
    };
</script>

I don't have the access to process.env.NODE_ENV !== "production" in index.html. Is there any other flag that I could use?

Alternatively, I could use try and catch

   try {
     window.SERVER_DATA = __SERVER_DATA__;
    } catch(e) {
      console.info('Development MODE', e)
      window.SERVER_DATA = {};
    }

But that's a syntax error.

1 Answers
Related