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
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.
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
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With