7
votes

My index.html file post ng build has the below files

<script type="text/javascript" src="inline.bundle.js"></script>
<script type="text/javascript" src="polyfills.bundle.js"></script>
<script type="text/javascript" src="styles.bundle.js"></script>
<script type="text/javascript" src="vendor.bundle.js"></script>

How can I make angular cli prepend 'app' in the src folder location, for example src="/app/vendor.bundle.js"

I would need to make the above change since I am loading all my static assets in dropwizard from a file system location starting with '/app/'

Below is my angular-cli.json for reference

angular-cli.json

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "project": {
    "name": "web"
  },
  "apps": [
    {
      "root": "src",
      "outDir": "dist",
      "assets": [
        "assets",
        "favicon.ico"
      ],
      "index": "index.html",
      "main": "main.ts",
      "polyfills": "polyfills.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.app.json",
      "testTsconfig": "tsconfig.spec.json",
      "prefix": "app",
      "styles": [
        "../node_modules/bootstrap/dist/css/bootstrap.min.css",
        "../node_modules/font-awesome/css/font-awesome.min.css",
        "../node_modules/primeng/resources/themes/ludvig/theme.css",
        "../node_modules/primeng/resources/primeng.min.css",
        "styles.css"
      ],
      "scripts": [],
      "environmentSource": "environments/environment.ts",
      "environments": {
        "dev": "environments/environment.ts"
      }
    }
  ],
  "e2e": {
    "protractor": {
      "config": "./protractor.conf.js"
    }
  },
  "lint": [
    {
      "project": "src/tsconfig.app.json"
    },
    {
      "project": "src/tsconfig.spec.json"
    },
    {
      "project": "e2e/tsconfig.e2e.json"
    }
  ],
  "defaults": {
    "styleExt": "css",
    "component": {}
  }
}
2
Could you add your .angular-cli.json config file ?Maxouhell
hi @Maxouhell , I have added the angular-cli contents aboveserah

2 Answers

13
votes

There is a deployUrl parameter inside your angular-cli.json :

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "project": {
    "name": "web"
  },
  "apps": [
    {
      "root": "src",
      "outDir": "dist",
      "deployUrl": "/app/",
      "assets": [
        "assets",
        "favicon.ico"
      ],
      "index": "index.html",

your imports will become :

<script type="text/javascript" src="/app/inline.bundle.js"></script>
<script type="text/javascript" src="/app/polyfills.bundle.js"></script>
<script type="text/javascript" src="/app/styles.bundle.js"></script>
<script type="text/javascript" src="/app/vendor.bundle.js"></script>

that's what you want ?

-2
votes

In your index.html you can include a base for you application, like

  <base href="/app">

Having said that, I am not sure if you really need that, Are you trying to host somewhere and facing some routing problem or anything ?