美文网首页
基于nrwl搭建项目

基于nrwl搭建项目

作者: zy_Judy | 来源:发表于2020-01-02 18:19 被阅读0次
创建项目

参考文章:

https://nx.dev/angular

https://ng.ant.design/docs/introduce/zh

https://antv.vision/zh

1,使用 npm init创建

npm init nx-workspace ng-demo

创建过程

image.png 2,添加ng-molain依赖 image.png

以上依赖需要切换到公司服务器下载

npm install -g nrm
nrm add parim http://npm.parim.net
nrm use parim

@ng-molain/components 还需要添加依赖ng-zorro-antd, cropperjs

cd ng-demo

ng add ng-zorro-antd
npm install cropperjs
npm install ngx-countdown
npm install file-saver
ng add @ng-molain/common
ng add @ng-molain/components

ng add @ng-molain/drag-drop

npm install @antv/g2
npm install @antv/data-set 
npm install @antv/g2-plugin-slider
ng add @ng-molain/g2-charts

另外需要在angular.json中引入js如下:
"scripts": [
"node_modules/@antv/g2/build/g2.js",
"node_modules/@antv/data-set/dist/data-set.min.js",
"node_modules/@antv/g2-plugin-slider/dist/g2-plugin-slider.min.js"
]

image.png

3,创建angular组件库

ng g @nrwl/angular:library course

因为新创建的模块名已经到基于 baseUrl 的路径映射的列表中,所以在应用中引入组件应

import { CourseModule } from '@ng-demo/course';

4,创建shared模块,包含全局应用到的公共模块,在tsconfig.json中添加映射路径,应用程序、组件库都可以引入。

5,打包时报错

Your global Angular CLI version (8.3.21) is greater than your local
version (8.3.14). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".
Browserslist: caniuse-lite is outdated. Please run next command `npm update`
Generating ES5 bundles for differential loading...
An unhandled exception occurred: Call retries were exceeded
See "C:\Users\EDZ\AppData\Local\Temp\ng-cZbxQ5\angular-errors.log" for further d
etails.

同样在日志中,提到[错误]错误:在ChildProcessWorker.initialize中超过了呼叫重试,解决方案:在package.json添加"build:demo"脚本为:ng build demo --prod --build-optimizer

相关文章

网友评论

      本文标题:基于nrwl搭建项目

      本文链接:https://www.haomeiwen.com/subject/abfooctx.html