How to configure a SPA on loading?

后端 未结 4 1681
孤独总比滥情好
孤独总比滥情好 2021-01-13 04:05

We are using Webpack, React, Node.JS but I think this question is more generic that the specific technologies. I can use Webpack to configure the SPA when building for deve

4条回答
  •  既然无缘
    2021-01-13 04:16

    One way is to rewrite the contents of the HTML file upon deploy.

    You can have a placeholder string, e.g. "$MY_CONFIG_HERE$" in your HTML.

    This can be in an some inline javascript tag on the page, which will set a javascript object on window.

    Then have your deploy process (Continuous Deploy) replace that string with the actual javascript object containing the data you want.

    Then, the data will be available on window to your javascript running in the Single Page App.

提交回复
热议问题