Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

angular6

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

like image 955
Morteza Ebrahimi Avatar asked Dec 11 '22 05:12

Morteza Ebrahimi


2 Answers

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

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

like image 160
Morteza Ebrahimi Avatar answered May 22 '23 20:05

Morteza Ebrahimi


Since version 2.3.0 of the ng-packagr, you need to add the keepLifecycleScripts-flag to the package.json, not to the ng-package.prod.json:

{
  "name": "xyz",
  "version": "1.0.0",
  "scripts": {
    "prepare": "..."
  },
  "ngPackage": {
    "keepLifecycleScripts": true
  }
}
like image 24
moritz.vieli Avatar answered May 22 '23 19:05

moritz.vieli