Including Assets in Your Build
All the official Nx executors with an assets
option have the same syntax.
There are two ways to identify assets to be copied into the output bundle:
- Specify assets with a regex string. This will copy files over in the same folder structure as the source files.
- Use the object format to redirect files into different locations in the output bundle.
project.json
1"build": {
2 "executor": "@nx/js:tsc", // or any other Nx executor that supports the `assets` option
3 "options": {
4 // shortened...
5 "assets": [
6 // Copies all the markdown files at the root of the project to the root of the output bundle
7 "path-to-my-project/*.md",
8 {
9 "input": "./path-to-my-project/src", // look in the src folder
10 "glob": "**/!(*.ts)", // for any file (in any folder) that is not a typescript file
11 "output": "./src" // put those files in the src folder of the output bundle
12 },
13 {
14 "input": "./path-to-my-project", // look in the project folder
15 "glob": "executors.json", // for the executors.json file
16 "output": "." // put the file in the root of the output bundle
17 }
18 ]
19 }
20}
21