Skip to content

Commit d048bfb

Browse files
filipesilvahansl
authored andcommitted
docs: update assets docs
1 parent dd97a7f commit d048bfb

File tree

1 file changed

+11
-29
lines changed

1 file changed

+11
-29
lines changed
Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Project assets
22

3-
You use the `assets` array in `.angular-cli.json` to list files or folders you want to copy as-is
4-
when building your project.
3+
You use the `assets` array inside the build target in `angular.json` to list files or folders
4+
you want to copy as-is when building your project.
55

66
By default, the `src/assets/` folder and `src/favicon.ico` are copied over.
77

88
```json
99
"assets": [
10-
"assets",
11-
"favicon.ico"
10+
"src/assets",
11+
"src/favicon.ico"
1212
]
1313
```
1414

@@ -18,45 +18,27 @@ The array below does the same as the default one:
1818

1919
```json
2020
"assets": [
21-
{ "glob": "**/*", "input": "./assets/", "output": "./assets/" },
22-
{ "glob": "favicon.ico", "input": "./", "output": "./" },
21+
{ "glob": "**/*", "input": "src/assets/", "output": "/assets/" },
22+
{ "glob": "favicon.ico", "input": "/src", "output": "/" },
2323
]
2424
```
2525

2626
`glob` is the a [node-glob](https://github.com/isaacs/node-glob) using `input` as base directory.
27-
`input` is relative to the project root (`src/` default), while `output` is
28-
relative to `outDir` (`dist` default).
27+
`input` is relative to the workspace root, while `output` is relative to `outDir`
28+
(`dist/project-name` default).
2929

3030
You can use this extended configuration to copy assets from outside your project.
3131
For instance, you can copy assets from a node package:
3232

3333
```json
3434
"assets": [
35-
{ "glob": "**/*", "input": "../node_modules/some-package/images", "output": "./some-package/" },
35+
{ "glob": "**/*", "input": "./node_modules/some-package/images", "output": "/some-package/" },
3636
]
3737
```
3838

3939
The contents of `node_modules/some-package/images/` will be available in `dist/some-package/`.
4040

4141
## Writing assets outside of `dist/`
4242

43-
Because of the security implications, the CLI will always refuse to read or write files outside of
44-
the project itself (scoped by `.angular-cli.json`). It is however possible to write assets outside
45-
the `dist/` build output folder during build.
46-
47-
Because writing files in your project isn't an expected effect of `ng build`, it is disabled by
48-
default on every assets. In order to allow this behaviour, you need to set `allowOutsideOutDir`
49-
to `true` on your asset definition, like so:
50-
51-
```json
52-
"assets": [
53-
{
54-
"glob": "**/*",
55-
"input": "./assets/",
56-
"output": "../not-dist/some/folder/",
57-
"allowOutsideOutDir": true
58-
},
59-
]
60-
```
61-
62-
This needs to be set for every assets you want to write outside of your build output directory.
43+
Because of the security implications, the CLI will always refuse to write files outside of
44+
the project output path.

0 commit comments

Comments
 (0)