-2

I am creating a library, which exposes some bin scripts to the user, which he then can use in his build process. However I have truble with exposing such scripts to a dist package.

My package.json looks like this:

{
  "name": "my-app",
  "bin": {
    "foobar": "./bin/custom-build.js"
  }
}

And a structure looks like this:

Project structure

When I run a build the custom-build.js is nowhere to be found in dist diresctory. My question is how do I expose such files?

Humberd
  • 2,794
  • 3
  • 20
  • 37

1 Answers1

-1

You should add them to angular.json. They will be combined into scripts.js in dist.

{
  "projects": {
    "your-project-name": {
      "architect": {
        "build": {
          "options": {
            "scripts": [
              "path/to/your/lib1.js",
              "path/to/your/lib2.js"
            ]
          }
        }
      }
    }
  }
}

Edit:

There is no option to copy file in Angular CLI. You can archive that by using external tool e.g. bash script, gulp https://gulpjs.com/

Then incorporate it into your package.js

{
  "scripts": {
    "build": "ng build && gulp bundle"
  }
}
Junx
  • 384
  • 3
  • 6