title: How can I deploy a spring-boot webapp with angular 2 frontend (angular-cli build) to Tomcat?
body: <p>I have a spring-boot web application and I build my frontend with angular-cli.  I have set the output directory of my angular build in <code>angular-cli.json</code> to resources/static and I have configured the build script in <code>package.json</code> like this:</p>
  
  <pre><code>"scripts" : {"build": "ng build --base-href /mywebapp", ...}
  </code></pre>
  
  <p>In the application.properties of the spring-boot configuration I have set the <code>server.contextPath</code> to 'mywebapp'.  </p>
  
  <p>But if I build the angular application the included js files of the created index.html in resources/static does not contain the server context path 'mywebapp':</p>
  
  <pre><code>&lt;script type="text/javascript" src="inline.bundle.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="polyfills.bundle.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>but I should look like this:</p>
  
  <pre><code>&lt;script type="text/javascript" src="/mywebapp/inline.bundle.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="/mywebapp/polyfills.bundle.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>So if I deploy my spring-boot app to tomcat the built index.html is load but it cannot find the imported js files and tries to load the files under <a href="http://localhost:8080/" rel="nofollow noreferrer">http://localhost:8080/</a> instead of <a href="http://localhost:8080/mywebapp/" rel="nofollow noreferrer">http://localhost:8080/mywebapp/</a>. </p>
  
  <p>How can I deploy a spring-boot application with an angular-frontend to a tomcat server if I don't want to deploy it under the root directory?</p>