Forum Discussion

ttadej's avatar
ttadej
Advisor
7 years ago

Local javascript development strategies?

Our team is trying to develop a solution to dev javascript locally. I don't think there is a solution for developing the @liaAddScript Javascript/jQuery in Freemarker files locally because that is bundled during deployment. I'm more interested in standalone files in web/html/assets/js or src/ - we have files in both places (one is a bundle and the others are standalone files).

 

We'd like to do something like this:

  • Serve up files from a local port
  • Manipulate the DOM to remove the static file includes from the hosted site and replace with the local versions
  • Watch file changes and reload accordingly

 

We're working on this now, but I'd be interested to hear if others have found a good solution. My initial thoughts are that it will require a number of npm packages and some hacks to the way the @includeScript function works in dev environments. Any input is appreciated! Thanks

  • ttadej - 

     

    For the CSS there is solution inside the LIthium already.  Using SDK, you can store the file on local and get it reflect on staging. You will find it in Advance - SDK - Responsive Skin CSS URL

     

    For JS, yes, you will need to store it on an external host. We have set-up a server but for the different purpose. Where we do upload file using git from the local folder.

     

    You will need to download git from here https://git-scm.com/download/win and set up it for your server.  It allows, to upload a single change in your files as well and detect automatically what has been changed or added or removed. 

     

    Below is an SS.

    http://prntscr.com/ixb3x6

     

    On the community end, you also to change the SRC of the script.  I think you can use any custom content, to store 0,1 where 1 mean the file will upload from a different server and 0 means JS file will upload from the community.  You will write this login inside the components as well where you have written the JS code.  Once you upload the new file, change the custom content value to 1 else 0. 

     

    I hope this will be helpful.