zl程序教程

您现在的位置是:首页 >  工具

当前栏目

ng 发布组件库

组件 发布 NG
2023-09-14 08:58:44 时间
  1. 创建一个空的项目
$ ng new ng-flt-flex --skipInstall --style=styl --createApplication=false --prefix=flt
  1. 创建组件库
$ ng generate library flt-flex
  1. 创建example
$ ng generate application example
  1. 打包组建库,将被打包到dist目录下
$ ng build flt-flex
  1. example 使用组件
import { AjanuwWidgetsModule } from 'ajanuw-widgets';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    AjanuwWidgetsModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
  1. 运行example
$ ng serve example

创建tar打包文件

$ cd dist/weather/
$ npm pack

$ cd ../../
$ npm install ./dist/weather/weatherweather-0.0.1.tgz

// 安装成功后后,删除tsconfig.json中的paths

发布npm包

$ cd dist/weather/
$ npm login
$ npm publish