1

I'm using Angular 14 and NPM 8. I have this command for building my artifact ...

npm run build -- --source-map --base-href=/my-app/ --output-path=dist/my-app/

The problem is, when my dist/my-app/index.html file is generated it contains the full path to my local machine

<!DOCTYPE html><html lang="en"><head>
  <meta charset="utf-8">
  <title>MyApp</title>
  <base href="C:/Program Files/Git/my-app/">

How do I run my build command such that my base href is only what is included after my "base-href" flag?

Dave
  • 15,639
  • 133
  • 442
  • 830
  • I just tested in my end and your command generated the expected output (I removed the extra `--` which is probably a typo). Can you also add your `tsconfig.json` file to the question? Is `baseUrl` value `"./"` or something else? – NeNaD Dec 30 '22 at 22:21

1 Answers1

0

Try to set baseUrl property in your tsconfig.json file like this:

{
  "compilerOptions": {
    "baseUrl": "./",
    ...
  },
}

baseUrl lets you set a base directory to resolve non-absolute module names.

You can define a root folder where you can do absolute file resolution.

With "baseUrl": "./" inside the project TypeScript will look for files starting at the same folder as the tsconfig.json.

NeNaD
  • 18,172
  • 8
  • 47
  • 89