0

I am using angluar cli to build my app.

Currently its building the app in dist folder

index.html

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Admin</title>
  <base href="/">

  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
  <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="styles.aa8ce79f832f8715c04d.css"></head>
<body>
  <app-root>
  </app-root>
<script type="text/javascript" src="runtime.d981c7f14a84cffbe02a.js"></script><script type="text/javascript" src="polyfills.c914ea4c8f6edd6e6f45.js"></script><script type="text/javascript" src="scripts.b5ea1a3cf9f89977f873.js"></script><script type="text/javascript" src="main.ebfc576e2cbf5f6d553e.js"></script></body>
</html>

I would like to customize all src path to have /app appended & look like:

<script type="text/javascript" src="/app/runtime.d981c7f14a84cffbe02a.js"></script>

Is there any way to achieve this?


2 Answers 2

1

You can use the deploy-url parameter when building your app

ng build --prod  --deploy-url /app/
Sign up to request clarification or add additional context in comments.

Comments

0

You want to prepend rather than append. Try changing your base href value so that all relative paths start from the app folder From:

<base href="/">
To:
<base href="./">

1 Comment

It's not about app folder, I am building angular to a springboot jar. It has a context of "/app" to it. In this case when I load index.html, the next GET to my server will be localhost:8080/runtime.js. This will be 404, it should be localhost:8080/app/runtime.js

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.