1. #1
    Sencha Premium Member
    Join Date
    Oct 2013
    Posts
    35
    Vote Rating
    3
    mattkim is on a distinguished road

      0  

    Default Index.html script tag switching between prod and dev configuration

    Index.html script tag switching between prod and dev configuration


    In my index.html I have a few script tags, that I need to switch depending on if it's building for dev or prod. Currently I'm manually doing this and I'm sure there is a better way. This is an example:

    Code:
    <script src="//myapp.com/socket.io/socket.io.js"></script>
    <!--<script  src="//localhost:3000/socket.io/socket.io.js"></script>  uncomment for dev, comment the other tag-->
    <script type="text/javascript"> 
      //window.BASE = 'http://localhost:3000/'; <-- uncomment for dev, comment the next line
      window.BASE = 'https://myapp.com';
      window.BASE_API = window.BASE + 'api/';
    </script>
    Can I automate this somehow?

  2. #2
    Sencha Premium Member
    Join Date
    Feb 2008
    Posts
    11
    Vote Rating
    3
    Kupuyc is on a distinguished road

      0  

    Default


    Hi.
    It's easy enough. Use -after-build hook in build.xml from your application dir.
    In one of my project I need to add build number for all compiled css and js files:
    Code:
    <target name="-after-build">
        <tstamp>
            <format property="build.version" pattern="yyMMddHHmm" locale="en,UK"/>
        </tstamp>
        <replace file="${build.page.file}" token=".css" value=".css?build=${build.version}"/>
        <replace file="${build.page.file}" token=".js" value=".js?build=${build.version}"/>
    </target>
    So, you may define property application.base in ./sencha/app/production.properties and ./sencha/app/testing.properties and just replace some peace of code in index.html file after build.

  3. #3
    Sencha Premium Member
    Join Date
    Oct 2013
    Posts
    35
    Vote Rating
    3
    mattkim is on a distinguished road

      0  

    Default


    Thanks so much!!!

Thread Participants: 1