Angular 如何建立和发布Library首发2023-12-14 08:57·编程生涯本文要点工程建立以及Library监理样式控制和生成(tailwindcss的使用)编译和打包发布到npm使用ng new project的命令方式进行建立工程。注:也可以创建工程,先不创建应用或library, 之后可以通过多应用方式来添加。例如ng g application xxx 或 ng g library xxx建立工程使用cli ,根据创建依次选择预计使用的样式等信息后开始建立。 $ ng new my-project ? Which stylesheet format would you like to use? SCSS [ https://sass-lang.com/documentation/syntax#scss ] ? Do you want to enable Server-Side Rendering (SSR) and Static Site Generation (SSG/Prerendering)? No CREATE my-project/README.md (1063 bytes) CREATE my-project/.editorconfig (274 bytes) CREATE my-project/.gitignore (548 bytes) CREATE my-project/angular.json (2786 bytes) CREATE my-project/package.json (1041 bytes) CREATE my-project/tsconfig.json (903 bytes) CREATE my-project/tsconfig.app.json (263 bytes) CREATE my-project/tsconfig.spec.json (273 bytes) CREATE my-project/.vscode/extensions.json (130 bytes) CREATE my-project/.vscode/launch.json (470 bytes) CREATE my-project/.vscode/tasks.json (938 bytes) CREATE my-project/src/main.ts (250 bytes) CREATE my-project/src/favicon1.ico (15086 bytes) CREATE my-project/src/index.html (295 bytes) CREATE my-project/src/styles.scss (80 bytes) CREATE my-project/src/app/app.component.scss (0 bytes) CREATE my-project/src/app/app.component.html (20884 bytes) CREATE my-project/src/app/app.component.spec.ts (928 bytes) CREATE my-project/src/app/app.component.ts (369 bytes) CREATE my-project/src/app/app.config.ts (227 bytes) CREATE my-project/src/app/app.routes.ts (77 bytes) CREATE my-project/src/assets/.gitkeep (0 bytes) ? Packages installed successfully. Successfully initialized git.加入library这里创建了一个library, 并加入到当前的工程中。建立完成后, 会再projects下建立对应的工程。 $ ng g library my-lib ? Would you like to share pseudonymous usage data about this project with the Angular Team at Google under Google's Privacy Policy at https://policies.google.com/privacy. For more details and how to change this setting, see https://angular.io/analytics. No Global setting: enabled Local setting: disabled Effective status: disabled CREATE projects/my-lib/README.md (978 bytes) CREATE projects/my-lib/ng-package.json (155 bytes) CREATE projects/my-lib/package.json (210 bytes) CREATE projects/my-lib/tsconfig.lib.json (314 bytes) CREATE projects/my-lib/tsconfig.lib.prod.json (240 bytes) CREATE projects/my-lib/tsconfig.spec.json (273 bytes) CREATE projects/my-lib/src/public-api.ts (118 bytes) CREATE projects/my-lib/src/lib/my-lib.component.spec.ts (590 bytes) CREATE projects/my-lib/src/lib/my-lib.component.ts (223 bytes) CREATE projects/my-lib/src/lib/my-lib.service.spec.ts (353 bytes) CREATE projects/my-lib/src/lib/my-lib.service.ts (134 bytes) UPDATE angular.json (3784 bytes) UPDATE package.json (1070 bytes) UPDATE tsconfig.json (975 bytes) ? Packages installed successfully.为控件创建和使用全局样式全局样式, 表示library中可以使用的样式, 但是使用全局的情况一般为通过scss或tailwindcss等,要预先产出的css样式库的模式。 正常libaray 可以不需要或使用时使用app.component.scss中定义组件自己的样式即可。因为这个工程会使用tailwindcss,所以工程中先引入tailwindcss 。所以 在project/my-lib 下建立assets用于放置一个全局的样式文件。将global.css放到打包设定中,通知包装要带入该样式文件。 { "$schema": "../../node_modules/ng-packagr/ng-package.schema.json", "dest": "../../dist/my-lib", "lib": { "entryFile": "src/public-api.ts" }, "assets": [ { "input": "src/assets", "glob": "**/*.css", "output": "assets" } ] }加入tailwindcss ,参考官方加入。 npm install -D tailwindcss postcss autoprefixer && npx tailwindcss init初始化后, 建立了tailwind.config.js的文件, 调整该文件如下: /** @type {import('tailwindcss').Config} */ module.exports = { content: [ "./src/**/*.{html,ts}", "./projects/my-lib/src/**/*.{html,ts}" ], theme: { extend: {}, }, plugins: [], }注,以上是最基本的配置, 如果要配置其他属性可参考官方设定。对于applcation 的工程,加入@tailwind 的定义。 @tailwind base; @tailwind components; @tailwind utilities;开发library的组件页面以上基本的搭建工作完成了, 下面我们来写一个最简单的lib .开启my-lib.component.ts的文件, 加入了tailwind的使用, 显示了4个div。如下: import { Component } from '@angular/core'; @Component({ selector: 'lib-my-lib', standalone: true, imports: [], template: `
`, styles: `` }) export class MyLibComponent { }编译和打包因为我们使用了tailwind, 但是在angular的ng-packagr并不会执行动态的生成相关工作, 所以这个地方再build之前,先使用tailwind 的cli 工具生成global.css的文件。 注意:tailwind会根据工程中使用的样式进行生成, 没有使用不会创建。 $ npx tailwindcss -o ./projects/my-lib/src/assets/global.css --minify Rebuilding... Done in 121ms. $ ng build my-lib --configuration production Building Angular Package ------------------------------------------------------------------------------ Building entry point 'my-lib' ------------------------------------------------------------------------------ ? Compiling with Angular sources in Ivy partial compilation mode. ? Generating FESM bundles ? Copying assets ? Writing package manifest ? Built my-lib $ cd ./dist/my-lib $ npm pack npm notice npm notice my-lib@0.0.1 npm notice === Tarball Contents === npm notice 978B README.md npm notice 2.8kB esm2022/lib/my-lib.component.mjs npm notice 1.4kB esm2022/lib/my-lib.service.mjs npm notice 480B esm2022/my-lib.mjs npm notice 615B esm2022/public-api.mjs npm notice 2.3kB fesm2022/my-lib.mjs npm notice 2.2kB fesm2022/my-lib.mjs.map npm notice 111B index.d.ts npm notice 264B lib/my-lib.component.d.ts npm notice 223B lib/my-lib.service.d.ts npm notice 523B package.json npm notice 78B public-api.d.ts npm notice === Tarball Details === npm notice name: my-lib npm notice version: 0.0.1 npm notice filename: my-lib-0.0.1.tgz npm notice package size: 3.9 kB npm notice unpacked size: 12.0 kB npm notice shasum: 8e90e3ff50fddc3cdeac4c6aa938afbb8ee57543 npm notice integrity: sha512-3P6YRElbEzl8A[...]HftBmHIJXoyjA== npm notice total files: 12 npm notice my-lib-0.0.1.tgz到此, 我们生成了my-lib的tgz的文件了。 其他工程可以引入使用。 当然我们也可以发布我们库到npm中。发布发布之前, 要有npm的账户哦。 如果没有登入请执行下面语句 $ npm login exit 1 npm notice Log in on https://registry.npmjs.org/ Login at: https://www.npmjs.com/login?next=/login/cli/xx Press ENTER to open in the browser... Logged in on https://registry.npmjs.org/.登入成功后, 就可以发布了。 $ npm publish exit 1 npm WARN publish npm auto-corrected some errors in your package.json when publishing. Please run "npm pkg fix" to address these errors. npm WARN publish errors corrected: npm WARN publish Removed invalid "scripts" npm notice npm notice my-lib-xx@0.0.1 npm notice === Tarball Contents === npm notice 978B README.md npm notice 5.0kB assets/global.css npm notice 2.8kB esm2022/lib/my-lib.component.mjs npm notice 1.4kB esm2022/lib/my-lib.service.mjs npm notice 480B esm2022/my-lib.mjs npm notice 615B esm2022/public-api.mjs npm notice 2.3kB fesm2022/my-lib.mjs npm notice 2.2kB fesm2022/my-lib.mjs.map npm notice 111B index.d.ts npm notice 264B lib/my-lib.component.d.ts npm notice 223B lib/my-lib.service.d.ts npm notice 527B package.json npm notice 78B public-api.d.ts npm notice === Tarball Details === npm notice name: my-lib-xx npm notice version: 0.0.1 npm notice filename: my-lib-xx-0.0.1.tgz npm notice package size: 5.7 kB npm notice unpacked size: 17.0 kB npm notice shasum: 19644a8e46c20e067d7c24d9d51ddd57b3846a0f npm notice integrity: sha512-tIJXZUPlRFjpT[...]fKDZ1PWvrtyLQ== npm notice total files: 13 npm notice npm notice Publishing to https://registry.npmjs.org/ with tag latest and default access + my-lib-xx@0.0.1注意, 不要重名, my-lib 因为有了对应的包了, 所以这里调整了一下包名后推送。使用lib使用和其他包使用过程一样。这里区分2种, 一个是当前工程内使用, 只需要执行了ng build ,应用程序的工程内即可使用该library了。 import { Component } from '@angular/core'; import { CommonModule } from '@angular/common'; import { RouterOutlet } from '@angular/router'; import { MyLibComponent } from '../../projects/my-lib/src/public-api'; @Component({ selector: 'app-root', standalone: true, imports: [CommonModule, RouterOutlet,MyLibComponent], templateUrl: './app.component.html', styleUrl: './app.component.scss' }) export class AppComponent { title = 'my-project'; }
注意,引入lib的css文件。可以看到样式已经出来了。如果是新增的工程,使用包, 可以如下:引入lib可以直接 npm install xxx的方式直接从npm 中下载, 也可以直接写路径。例如: "my-lb-xx": "/Users/xxx/dist/my-lib/my-lib-0.0.11.tgz",引入css可以直接调整style.scss加入引用 @import "../node_modules/aiwow-chat/assets/global.css"然后需要的组件就可以开始使用了。
2024年12月30日,在仓储物流的管理中,奥乐齐与供应商共享销售数据。这种数据共享显着提升了供应链的透明度和效率,不仅让供应商能够实时了解销售情况,而且结合市场趋势分析,供应商可以更准确地预测市场的需求变化。
《风流情圣》全集手机在线观看 - 黑米影院《风流情圣》高清在线观看-免费下载-神马影院
难道金融机构的办事方式如此不灵活作为金融从业人士解解感受到的是银行工作人员的糊弄和拖延其实除了本人线下办理还可以线上授权或者邮寄材料本人签字但是工作人员并未告知甚至最后冷暴力不回应
这起事件也引发了人们对教育体系的反思。许多家长和教育工作者呼吁,应该建立更完善的机制来处理师生矛盾,防止类似事件的再次发生。②来点汤开胃:菜汤、肉汤、鱼汤、蛋汤等,餐前少量饮用还能增加食欲。
zhegejiaweideche,qishimeishimehaoshuode,tongjiaweidexinnengyuanchexing,kenengzaipeizhihetiyancengmian,gengyouyoushi,danshiluoshidaozhengchedeanquanxinghekekaoxing,yijishouhoufuwuwangluohepinpaiyingxianglilaishuo,zuoyuezheyidianyoushihuanshimingxian。beikaojili,jiyuBMAjiagoudazaoerlai,changxiaoduonian,shijingguoliaochongfenshichangjianyan,wendingkekaoxingyoubaozheng,qiezhecixinchechaonengbanhuanzaiwaiguanneishidushixianliaoshengji,zaitongjibiechexingzhongyijingsuanbucuoliao。yuanchuang2024-07-12 11:01·jimuxinwen
据(闯耻)报(叠补辞)道(顿补辞),摩(惭辞)根(骋别苍)士(厂丑颈)丹(顿补苍)利(尝颈)本(叠别苍)周(窜丑辞耻)上(厂丑补苍驳)调(顿颈补辞)了(尝颈补辞)经(闯颈苍驳)济(闯颈)增(窜别苍驳)长(颁丑补苍驳)预(驰耻)测(颁别),称(颁丑别苍驳)拜(叠补颈)登(顿别苍驳)总(窜辞苍驳)统(罢辞苍驳)的(顿别)基(闯颈)础(颁丑耻)设(厂丑别)施(厂丑颈)法(贵补)案(础苍)推(罢耻颈)动(顿辞苍驳)了(尝颈补辞)“大(顿补)规(骋耻颈)模(惭辞)基(闯颈)础(颁丑耻)设(厂丑别)施(厂丑颈)”的(顿别)建(闯颈补苍)设(厂丑别)。
sanfutian,duochizhengcaishentihao!shouxuanzhe5yang,qingshuangbuyouni,haochibushanghuoyuanchuang2022-07-24 16:08·diyimeishidashuguohou,erfuyeyaodaoliao。tianqiyichangdeyanre,zuofanyefeichangdejianao,rendeweikouyehuibiandehencha。suoyi,meidaozhegeshihou,jialimianduhuizuoxiezhengcai,yishizhengcainengzuidachengdudibaoliushiwudeyingyang;ershi,diyoudizhidiyan,qingdanshaoyou,haochihuanbushanghuo。zhengyizhengbufeijin,shengshiyoushengli,youqishihexiaohuagongnengjiaoruodelaorenhehaizi,bufangshizhuozuoyizuoba。yi、zhengdoujiao1.zhunbeiyibaxiganjingchangdoujiao,liangganshuifenyihou,qiechengsuilifangrupenzhong,daruyigejidanjiaobanjunyun,zaifangrushiliangdemianfenjixujiaoban。2.rangdoujiaobiaomianjunyunguoshangmianfen,xiangzheyangyiliyilisankai,buzhanliandezhuangtaijiukeyiliao,ranhoulinruyidianzhiwuyou,jiarushiyan2kezaicibanyunjiunengshangguozhengliao。3.guoneishaoshui,fangshangzuozi,shuishaokaiyihoubadoujiaofangruguozhongtankai,shangqiyihouzheng5fenzhong。zhenghaohouwomenbadoujiaoquchulaifangrupenzhong,kuaisuyongkuaizidousanyimianzhanzaiyiqi,jiarujifen1ke,linruyidianzhimaxiangyoujiaobanjunyun,yidaoqingxiangmeiweidezhengdoujiaojiuzuohaoliao。er、zhengzuocai1.zhunbeiyibazuocai,zhaixianenye,fangzaipenli。jiaruqingshuixijing,duoqingxijibian,ranhoukongganshuifen。bazuocaikongganshuifenhou,fangzaipenlijiaruzhiwuyou,yongshouzhuayun。ranhouzaifangrumianfen,jiaobandaokanbudaolvyeweizhi。2.bazuocaishangguozhengyixia。guoneishaoshui,fangshangbizi,gaishangguogai,kaidahuo,bashuishaokaihou,fangrubanhaomianfendezuocaiye,zuocaifeichanghaoshu,yibanzhengsanfenzhongzuoyoujiukeyiliao。sanfenzhonghou,babiziduanchuguo,bazuocaiyedaorupenzhongdousan,yidingyaozaiwendumeiyouliangxialaizhiqianbansan。sashangyidianshiyan,dianpanbanyunhou,zhuangzaipanli。3.diaoyixiawei。daoyidiansuanni。daosuannishijiayidianshiyan,zaidaoruzhimayou,hongyou,shengchoujiaobanjunyun。daozaizhenghaodezuocaishang。haoliao,zhedaoyingyangmeiweidezhengzuocaijiuzuohaoliao。san、nongjiazhengdoufu1.zhunbeiyikuaidoufu。ranhouqiepian,buyaoqiedetaibao,qiedoufudeshihourongyizhandaozuihaoshidaozhuoqie,qiexialaidedoufukuaiyongshouanzhubuhuizhanzaidaoshang。qiehaohouanzhaoshunxubaifangzaipanzhong。ranhouzhunbeixiaocongyixiaobaqiechengxiaoconghua,xiaomijiaojiliqiechenglajiaoquan,dasuanjilipaibianyihouqiechengsuanmo。2.zhunbeiyigexiaowandiaogexiaoliao,daoruzhengyuzuoyou10ke、zhimaxiangyou3ke、baitang2ke、jiaruyidianwenkaishui、zaijiarushengchou3ke,xiaoshaozijiaobanhuakaidiaoliao。3.guoneishaoshuifangshangzuozi,badoufufangzaizuozishangmiankaizhonghuozheng8fenzhong。8fenzhongyihouxiankaiguogai,ranhoubapanzizhongdetangzhiquanbudaodiao,sashangconghua、suanmohexiaomijiaozhuashangjilihuajiao。guoneizaishaoyoubayoushaozhimaoqingyan,jiaozaishangmianreyoujichuxiaoconghehuajiaodexiangweijiukeyishiyongliao。si、xiangguhuaji1.zhunbeiliangzhiroujitui,yongdaohuakai,xixitiqugutou,ranhoubashengxiaderoukuaiqiechengfangding。qiedacongbaiyiduan,xianpaibianzaihuakai,qiechengchangtiao。shengjiangyikuai,paibianhouqiechengsuili。zhihouwangpenlijiarushiliangshiyan,hujiaofen,zuoyou,liaojiu,shengchou,sangeqiesandeganhongjiao,dazuoliangli,huajiaoyixiaoba,jiaobanjunyunzuozhi20fenzhong。2.yongdaoqiequxianggudegenbu。guolitianyixieshui,shaokaihoudaoruxianggu,zuoshui1fenzhong。laochuhou,yongliangshuichongxi。jirouzuohaoyihou,jianchuqizhongzuoliao,ranhousarudianfen,geijiroujunyunguoshang。bazuoguoshuidexiangguqiechengpian,pingsanbaizaipandi,ranhoudaoshangjirou。3.jiexialaifangguoli,zhonghuozheng20fenzhong。20fenzhonghou,quchujirou,ruguotangzhitaiduo,keyidaodiaoyixie。zuihousashangconghua,jiukeyishangzhuoliao。zhedaomeiweixiangnongdexiangguhuajijiuzuohaoliao,zuoyiguoyingyangyouzibu。wu、qingzhengyuwei1.zhunbeiyitiaohuazuo,cishaodeyuchizhuobijiaodejin。xiyixia,quchufubudeheimohecanliudexueshui,zheyangchideshihoucaibuhuixing。xiganjingyihou,qiechengyilimihoudeyukuai,junyundimafangzaipanzilimian。2.dacongquchugeyingxin,qiechengxisi,shengjiangyeqiechengxisi。qingjiao、hongjiaogebange,baziquchu,yiqiqiechengsi,quanbuyongqingshuipaoshang。3.zhengguoshangqiyihou,bayukuaifangjinqu,gaishangguogaizheng10fenzhongjiukeyiliao,10fenzhongyihouwomenbayukuaiquchulai。junyunsashangcongjiangsiheqinghongjiaosi,zaijiaoshang200dudereyou,jifachuxiangwei,linshangzhengyuzuoyou。yidaoyingyangmeiweideqingzhengyuweijiuzuohaoliao。(diyimeishibianji:kaixin)zhejianshiqingshishouhaifangshiweinansheng,ruguohuanzuonvxingdajiahuanhuizhemekuanrongdaduma?
大(顿补)约(驰耻别)这(窜丑别)就(闯颈耻)是(厂丑颈)受(厂丑辞耻)过(骋耻辞)创(颁丑耻补苍驳)伤(厂丑补苍驳)的(顿别)人(搁别苍)的(顿别)一(驰颈)种(窜丑辞苍驳)正(窜丑别苍驳)常(颁丑补苍驳)状(窜丑耻补苍驳)态(罢补颈)。
在这次调整中,阿里中国商业版图结束了刻意区分以淘宝为代表的个体商家和以天猫为代表的品牌商家的组织框架。不过,由于吹雪的离职消息传出,引发了外界对淘宝天猫可能拆分的联想。嘉行传媒一度传出要冲击A股上市的消息,但一直未见嘉行传媒有任何动作。直到2022年6月陕西公布的360家后备上市公司名单中,嘉行传媒出现在C档,它要上市的消息又引起了人们的关注。《风流情圣》全集手机在线观看 - 黑米影院《风流情圣》高清在线观看-免费下载-神马影院
对李成儒说:这个人我看上了很符合女儿国国王的角色气质
声明:该文观点仅代表作者本人,搜狐号系信息发布平台,搜狐仅提供信息存储空间服务。