Search code examples
angularnpmangular-libraryng-packagr

How to add bin script to Angular's ng-package generated library


Inside Angular library project I have a script

  "bin": {
    "some-script": "./.bin/some-script.js"
  },

but when I build the project with :

ng build project-name --prod

then some-script.js is not included in the output (dist folder) nor in the package (npm pack).

How can I add it to the dist folder?


Solution

  • You can add it as an asset of the ng-packagr configuration.

    ng-package.json

    {
        "assets": [
            ".bin/some-script.js"
        ],
        "lib": {
            ...
        }
    }
    

    More info: https://github.com/ng-packagr/ng-packagr/blob/master/docs/copy-assets.md