我有一个用angular-cli开发的应用程序.作为构建过程的一部分,我们运行单元测试并在VSTS中显示结果.
如何以xml格式生成单元测试结果,以便我可以将其与VSTS集成?
提前致谢.
错误:
Uncaught Error: Cannot enable prod mode after platform setup. at main.bundle.js:1
Run Code Online (Sandbox Code Playgroud)
案件:
在使用生成构建之后,应用程序启动时出错ng build --prod.但是,使用ng serve或编译的开发构建ng build工作正常.
我尝试了什么:
- 升级全局和本地@angular/cli到最新版本,即1.6.0遵循此答案.
的package.json:
{
"dependencies": {
"@angular/animations": "^5.0.0",
"@angular/common": "^5.0.0",
"@angular/compiler": "^5.0.0",
"@angular/core": "^5.0.0",
"@angular/forms": "^5.0.0",
"@angular/http": "^5.0.0",
"@angular/platform-browser": "^5.0.0",
"@angular/platform-browser-dynamic": "^5.0.0",
"@angular/router": "^5.0.0",
"auth0-js": "^8.11.3",
"bootstrap": "^3.3.7",
"core-js": "^2.4.1",
"jquery": "^3.2.1",
"rxjs": "^5.5.2",
"zone.js": "^0.8.14"
},
"devDependencies": {
"@angular/cli": "^1.6.0",
"@angular/compiler-cli": "^5.0.0",
"@angular/language-service": "^5.0.0",
"@types/jasmine": "~2.5.53",
"@types/jasminewd2": "~2.0.2", …Run Code Online (Sandbox Code Playgroud) 我们正在使用开发一个应用程序Angular 5。运行ng build --prod --aot并将dist文件夹部署到主软件包产生的dev服务器之后2.2MB on initial load。与8MB供应商捆绑包的大小(运行ng build --prod时)相比,它已经很小了,但仍然需要减小主捆绑包的大小。有什么方法可以减小主捆的尺寸?
我有一个Angular CLI项目,我刚刚升级到Angular 6.现在,当我尝试构建我的应用程序时,出现以下错误:
ERROR in ./node_modules/postcss/lib/input.js
Module not found: Error: Can't resolve 'path' in '/Users/jattardi/code/myproject/node_modules/postcss/lib'
ERROR in ./node_modules/postcss/lib/map-generator.js
Module not found: Error: Can't resolve 'path' in '/Users/jattardi/code/myproject/node_modules/postcss/lib'
ERROR in ./node_modules/postcss/lib/previous-map.js
Module not found: Error: Can't resolve 'path' in '/Users/jattardi/code/myproject/node_modules/postcss/lib'
ERROR in ./node_modules/htmlparser2/lib/WritableStream.js
Module not found: Error: Can't resolve 'stream' in '/Users/jattardi/code/myproject/node_modules/htmlparser2/lib'
我糊涂了.首先,我甚至没有使用postcss或htmlparser2直接在我的项目中.所以他们必须是其他东西的依赖.
但是不是path并且stream内置Node模块?怎么可能无法解决它们?
我有一个简单的Angular CLI(6.0.7)应用程序,它在src/assets/文件夹中有一些资产.其中一些在Angular组件的CSS文件中被引用.例:
/* src/app/app.component.css */
.test-div {
background: url(../assets/test.png);
}
Run Code Online (Sandbox Code Playgroud)
当我构建项目时,ng build我最终得到一个像这样的输出结构:
dist/
myapp/
assets/
test.png <-- This one is simply copied from the src/asssets folder
index.html
main.js
test.png <-- This one is created by magic Angular CSS processing
...
Run Code Online (Sandbox Code Playgroud)
此外,CSS被重写为指向test.png根目录中的test.png文件而不是文件assets夹中的文件.
我根本不喜欢这种行为.我知道在生产模式下编译应用程序时会有一些好处,它会为从CSS引用的资产文件添加一些哈希前缀以防止缓存,但我不喜欢文件重复以及CSS中引用的资产与手动引用的资产之间的不一致打字稿.所以我宁愿禁用这种特殊的CSS处理,因此Angular不会解析CSS中的URL并保持URL不变.
那么如何禁用Angular CLI的神奇CSS处理呢?
我有一个使用Angular CLI 6(6.08)生成的Angular 6项目.
我使用ng generate library [lib name] --prefix [lib prefix](本文中概述的方法:https://medium.com/@tomsu/how-to-build-a-library-for-angular-apps-4f9b38b0ed11)创建了单独的库.
我使用构建每个库ng build [lib name],然后使用我的应用程序ng serve.
但是,当我在Chrome开发工具中查看源代码时,我的库没有源映射.
我已经尝试使用ng build [lib name] --source-map(如此处指定的:https://github.com/angular/angular-cli/wiki/build)构建每个库,但我认为这仅用于构建该应用程序,而不是库.
有谁知道我做错了有另一种解决方案吗?
Angular CLI项目中是否有方法让库提供polyfill?在内部angular.json,主应用程序默认配置为"polyfills": "src/polyfills.ts".此选项不适用于库项目.
我的具体用例是我的库有一个需要polyfill的依赖项.如果库无法在应用程序中导入polyfill时自动提供polyfill,我需要记录并通知库用户自己添加polyfill.
我遇到问题,请帮助我解决此问题。问题是当我ng build在CLI中执行操作时,转到dist文件夹并运行index.html文件,以便控制台获取文件路径错误。
Failed to load resource: net::ERR_FILE_NOT_FOUND
polyfills.js:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
styles.js:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
scripts.js:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
vendor.js:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
main.js:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
/D:/favicon.ico:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
Run Code Online (Sandbox Code Playgroud) 我在我的应用程序中使用Angular 7,在开发服务器上运行它时出现错误。
我没有服务
但是我下面有错误
D:\suman\ftoss\New TFS\FtossAngularWeb\Pre11WebV1>ng lint -fix Your
global Angular CLI version (7.3.9) is greater than your local version
(7.1.4). The local Angular CLI version is used.
To disable this warning use "ng config -g cli.warnings.versionMismatch
false".
Schema validation failed with the following errors:
Data path ".builders['app-shell']" should have required property 'class'.
Error: Schema validation failed with the following errors:
Data path ".builders['app-shell']" should have required property 'class'.
at MergeMapSubscriber.project (D:\suman\ftoss\New TFS\FtossAngularWeb\Pre11WebV1\node_modules\@angular-devkit\core\src\workspace\workspace.js:215:42)
at MergeMapSubscriber._tryNext (D:\suman\ftoss\New TFS\FtossAngularWeb\Pre11WebV1\node_modules\rxjs\internal\operators\mergeMap.js:69:27)
at MergeMapSubscriber._next …Run Code Online (Sandbox Code Playgroud) 尝试运行命令时出现以下错误
ng update @angular/cli @angular/core --allow-dirty
Repository is not clean. Update changes will be mixed with pre-existing changes.
Using package manager: 'npm'
Collecting installed dependencies...
Found 28 dependencies.
Package '@angular/cli' is not a dependency.
Run Code Online (Sandbox Code Playgroud) angular-cli ×10
angular ×7
angular5 ×2
typescript ×2
webpack ×2
angular6 ×1
angular7 ×1
aot ×1
console.log ×1
ng-build ×1
ng-packagr ×1
node.js ×1
npm ×1