<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> ## Current Behavior <!-- This is the behavior we have today --> ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes https://github.com/nrwl/nx/issues/22948
32 lines
1.2 KiB
Markdown
32 lines
1.2 KiB
Markdown
# 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:
|
|
|
|
1. Specify assets with a regex string. This will copy files over in the same folder structure as the source files.
|
|
2. Use the object format to redirect files into different locations in the output bundle.
|
|
|
|
```jsonc {% fileName="project.json" %}
|
|
"build": {
|
|
"executor": "@nx/js:tsc", // or any other Nx executor that supports the `assets` option
|
|
"options": {
|
|
// shortened...
|
|
"assets": [
|
|
// Copies all the markdown files at the root of the project to the root of the output bundle
|
|
"path-to-my-project/*.md",
|
|
{
|
|
"input": "./path-to-my-project/src", // look in the src folder
|
|
"glob": "**/!(*.ts)", // for any file (in any folder) that is not a typescript file
|
|
"output": "./src" // put those files in the src folder of the output bundle
|
|
},
|
|
{
|
|
"input": "./path-to-my-project", // look in the project folder
|
|
"glob": "executors.json", // for the executors.json file
|
|
"output": "." // put the file in the root of the output bundle
|
|
}
|
|
]
|
|
}
|
|
}
|
|
```
|