1
1
# Project assets
2
2
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.
5
5
6
6
By default, the ` src/assets/ ` folder and ` src/favicon.ico ` are copied over.
7
7
8
8
``` json
9
9
"assets" : [
10
- " assets" ,
11
- " favicon.ico"
10
+ " src/ assets" ,
11
+ " src/ favicon.ico"
12
12
]
13
13
```
14
14
@@ -18,45 +18,27 @@ The array below does the same as the default one:
18
18
19
19
``` json
20
20
"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" : " /" },
23
23
]
24
24
```
25
25
26
26
` 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).
29
29
30
30
You can use this extended configuration to copy assets from outside your project.
31
31
For instance, you can copy assets from a node package:
32
32
33
33
``` json
34
34
"assets" : [
35
- { "glob" : " **/*" , "input" : " .. /node_modules/some-package/images" , "output" : " . /some-package/" },
35
+ { "glob" : " **/*" , "input" : " ./node_modules/some-package/images" , "output" : " /some-package/" },
36
36
]
37
37
```
38
38
39
39
The contents of ` node_modules/some-package/images/ ` will be available in ` dist/some-package/ ` .
40
40
41
41
## Writing assets outside of ` dist/ `
42
42
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