https://stackblitz.com/edit/angular-ngx-daterangepicker-material-build-problem
这在使用时有效,ng serve
但我使用构建整个角度应用程序ng build --prod
,问题如下
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
并且由于 stackblitz 导出不包含环境目录,您应该通过添加此类文件或评论此行来解决问题angular.json
第二个问题是 stackblitz 提供的旧版本的角度依赖,所以我将它们更新packages.json
为ng new myApp
生成的内容。
"@angular/animations": "~9.0.1",
"@angular/common": "~9.0.1",
"@angular/compiler": "~9.0.1",
"@angular/core": "~9.0.1",
"@angular/forms": "~9.0.1",
"@angular/platform-browser": "~9.0.1",
"@angular/platform-browser-dynamic": "~9.0.1",
"@angular/router": "~9.0.1",
"@angular-devkit/build-angular": "~0.900.2",
"@angular/cli": "~9.0.2",
"@angular/compiler-cli": "~9.0.1",
"@angular/language-service": "~9.0.1",
"typescript": "~3.7.5"
最后它成功构建使用ng build --prod