[英]How to create components in npm package for angular projects
I have multi angular projects and i will use the multi-components that I created to use in other my projects. 我有多个角度的项目,我将使用自己创建的要在其他项目中使用的多个组件。 My projects is: 我的项目是:
+ shop
- src
- app
- components
- e2e
- angular.json
- package.json
- tsconfig.json
+ site
- src
- app
- components
- e2e
- angular.json
- package.json
- tsconfig.json
....
I will create multi-component in npm for use in all my projects. 我将在npm中创建多组件,以在所有项目中使用。 How i create npm package? 我如何创建npm包?
you could create a library with 您可以使用创建一个库
ng generate library my-library
and move your components to projects/my-library
. 并将您的组件移至projects/my-library
。
To build it, you can run 要构建它,您可以运行
ng build my-library
The result of the build will be a publishable npm package. 构建的结果将是可发布的npm软件包。 To publish it, run 要发布它,运行
cd dist/my-library
npm publish
see https://angular.io/guide/creating-libraries and https://angular.io/cli/generate#library 参见https://angular.io/guide/creating-libraries和https://angular.io/cli/generate#library
Find it. 找到它。 Use from Verdaccio
package. 从Verdaccio
软件包中使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.