config.js 多人同步更新 解决方案 多项目公用一套config.js dev

index.html

<script type='text/javascript' src='<%= BASE_URL %>config.js?${Math.random().toString(36).substr(2)}'></script>

  <% if (process.env.NODE_ENV === 'development') { %>
  <script>
    console.info('window.location.hostname', window.location.hostname)
    var oHead = document.getElementsByTagName('head')[0]; // 在head标签中创建创建script
    var oScript = document.createElement("script");
    oScript.type = "text/javascript";
    var rootDirectory = "<%= BASE_URL %>"
    // var rootDirectory = "/your_web/"
    oScript.src = rootDirectory + "configDev/configjs" + window.location.hostname + ".js?${Math.random().toString(36).substr(2)}";
    oHead.appendChild(oScript);
  </script>
  <% } %>


思路:

config.js 多人同步更新 解决方案

多人提交git config总会被覆盖,调试时候,用ip作为文件名,这样后置盖回来就解决多人同步更新config的问题了。

多项目公用一套config.js dev

将平台的二次加载地址,不用自己的,用另一个项目的加载地址即可 改 rootDirectory

posted @ 2021-11-17 09:40  彭成刚  阅读(99)  评论(0编辑  收藏  举报