4

I am working on POC where we have to package angular dist folder in spring mvc based web application(single war). This will be deployed in weblogic and tomcat. War file will serve the static content which is angular 2 app.

Now what i noticed is that when angular-cli builds the app, it is updating index.html with "script" tag to point to generated "js" files. I want to customize this script tag so that i can add "context" name in the url.

Is this something can be done? Or If I have to use webpack, does webpack support this customization?

here is example of script tag i would like to add during angular-cli build process

<script type="text/javascript" src="<CONTEXT-NAME>/inline.bundle.js"></script>
user509755
  • 2,941
  • 10
  • 48
  • 82

3 Answers3

1

@angular-builders/custom-webpack allows you to customize Angular build.
indexTransform option allows you to modify index.html (including script tags).

Disclaimer: I'm the owner of this project

JeB
  • 11,653
  • 10
  • 58
  • 87
0

Have you tried this:

https://stackoverflow.com/a/40120805/2637605

For your specific techonolgy stack (Spring MVC with Angular) you might want to look into JHipster:

https://jhipster.github.io/

Community
  • 1
  • 1
  • Yes, I tried your first option and it stills copy in "dist" folder only. – user509755 Feb 16 '17 at 13:27
  • What version of angular-cli are you using? – Mikael Kristensen Feb 16 '17 at 13:35
  • 1
    "angular-cli": "1.0.0-beta.28.3". So i am able to fix the folder where it suppose to copy but my problem is when angular-cli updated index.html, i want specific context name being added in each script tag. So I am not sure this is the correct solution as it just copies the files in specific folder. – user509755 Feb 16 '17 at 13:43
0

In case someone comes upon this, you may set the script src prefix in the .angular-cli.json file

  "apps": [
    {
      "deployUrl": "<CONTEXT-NAME>/"
    }]
Ulfius
  • 619
  • 7
  • 14