Search code examples
angular6

Prevent to remove script section of package.json (library angular)


I made a library with angular 6. When I build the library, script section of package.json will be removed. How can I prevent this?(I need script section after library was built)

How to build: ng build --prod MyLibraryName


Solution

  • Angular library uses ng-packagr package. When you generete a library by cli, ng-package.json will be added into your library(for setting of the package).

    If you add "keepLifecycleScripts": true into ng-package.json, the script section of the package.json won't be removed in building the library.