[英]How do I get "--base-href" to not expand to an absolute path when building using npm?
I'm using Angular 14 and NPM 8. I have this command for building my artifact...我正在使用 Angular 14 和 NPM 8。我有这个命令来构建我的工件......
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问题是,当我的 dist/my-app/index.html 文件生成时,它包含我本地机器的完整路径
<!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?如何运行我的构建命令,使我的基本 href 仅包含在我的“base-href”标志之后?
Try to set baseUrl
property in your tsconfig.json
file like this:尝试在
tsconfig.json
文件中设置baseUrl
属性,如下所示:
{
"compilerOptions": {
"baseUrl": "./",
...
},
}
baseUrl
lets you set a base directory to resolve non-absolute module names.baseUrl
允许你设置一个基目录来解析非绝对模块名称。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 thetsconfig.json
.在项目 TypeScript 中使用
"baseUrl": "./"
将查找从与tsconfig.json
相同的文件夹开始的文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.