Skip to content

Commit f776fe9

Browse files
committed
feat(@schematics/angular): replace assets with public directory
The `assets` directory is confusing for the users and commonly users place "assets" which are not meant to be copied but instead processed by the build system. This causes some files both bundled and copied. With this change we rename the `assets` directory to `public` and also move the `favicon.ico` inside this newly created directory.
1 parent c7b2085 commit f776fe9

File tree

24 files changed

+64
-68
lines changed

24 files changed

+64
-68
lines changed

goldens/public-api/angular_devkit/build_angular/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export interface AssetPatternObject {
8181
glob: string;
8282
ignore?: string[];
8383
input: string;
84-
output: string;
84+
output?: string;
8585
}
8686

8787
// @public

packages/angular/pwa/pwa/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,15 @@ export default function (options: PwaOptions): Rule {
146146
const { title, ...swOptions } = options;
147147

148148
await writeWorkspace(host, workspace);
149+
let assetsDir = posix.join(sourcePath, 'assets');
150+
if (!host.exists(assetsDir)) {
151+
assetsDir = posix.join(sourcePath, 'public');
152+
}
149153

150154
return chain([
151155
externalSchematic('@schematics/angular', 'service-worker', swOptions),
152156
mergeWith(apply(url('./files/root'), [template({ ...options }), move(sourcePath)])),
153-
mergeWith(apply(url('./files/assets'), [move(posix.join(sourcePath, 'assets'))])),
157+
mergeWith(apply(url('./files/assets'), [move(assetsDir)])),
154158
...[...indexFiles].map((path) => updateIndexFile(path)),
155159
]);
156160
};

packages/angular/pwa/pwa/index_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe('PWA Schematic', () => {
5454

5555
it('should create icon files', async () => {
5656
const dimensions = [72, 96, 128, 144, 152, 192, 384, 512];
57-
const iconPath = '/projects/bar/src/assets/icons/icon-';
57+
const iconPath = '/projects/bar/src/public/icons/icon-';
5858
const tree = await schematicRunner.runSchematic('ng-add', defaultOptions, appTree);
5959

6060
dimensions.forEach((d) => {

packages/angular_devkit/build_angular/src/builders/application/schema.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,11 +560,12 @@
560560
},
561561
"output": {
562562
"type": "string",
563+
"default": "",
563564
"description": "Absolute path within the output."
564565
}
565566
},
566567
"additionalProperties": false,
567-
"required": ["glob", "input", "output"]
568+
"required": ["glob", "input"]
568569
},
569570
{
570571
"type": "string"

packages/angular_devkit/build_angular/src/builders/browser-esbuild/schema.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,11 +466,12 @@
466466
},
467467
"output": {
468468
"type": "string",
469+
"default": "",
469470
"description": "Absolute path within the output."
470471
}
471472
},
472473
"additionalProperties": false,
473-
"required": ["glob", "input", "output"]
474+
"required": ["glob", "input"]
474475
},
475476
{
476477
"type": "string"

packages/angular_devkit/build_angular/src/builders/browser/schema.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,11 +454,12 @@
454454
},
455455
"output": {
456456
"type": "string",
457+
"default": "",
457458
"description": "Absolute path within the output."
458459
}
459460
},
460461
"additionalProperties": false,
461-
"required": ["glob", "input", "output"]
462+
"required": ["glob", "input"]
462463
},
463464
{
464465
"type": "string"

packages/angular_devkit/build_angular/src/builders/karma/schema.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@
290290
},
291291
"output": {
292292
"type": "string",
293+
"default": "",
293294
"description": "Absolute path within the output."
294295
},
295296
"ignore": {
@@ -301,7 +302,7 @@
301302
}
302303
},
303304
"additionalProperties": false,
304-
"required": ["glob", "input", "output"]
305+
"required": ["glob", "input"]
305306
},
306307
{
307308
"type": "string"

packages/angular_devkit/build_angular/src/builders/server/schema.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,12 @@
251251
},
252252
"output": {
253253
"type": "string",
254+
"default": "",
254255
"description": "Absolute path within the output."
255256
}
256257
},
257258
"additionalProperties": false,
258-
"required": ["glob", "input", "output"]
259+
"required": ["glob", "input"]
259260
},
260261
{
261262
"type": "string"

packages/angular_devkit/build_angular/src/builders/web-test-runner/schema.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@
269269
},
270270
"output": {
271271
"type": "string",
272+
"default": "",
272273
"description": "Absolute path within the output."
273274
},
274275
"ignore": {
@@ -280,7 +281,7 @@
280281
}
281282
},
282283
"additionalProperties": false,
283-
"required": ["glob", "input", "output"]
284+
"required": ["glob", "input"]
284285
},
285286
{
286287
"type": "string"

packages/angular_devkit/build_angular/src/tools/webpack/utils/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ export function assetPatterns(root: string, assets: AssetPatternClass[]) {
231231
return assets.map((asset: AssetPatternClass, index: number): ObjectPattern => {
232232
// Resolve input paths relative to workspace root and add slash at the end.
233233
// eslint-disable-next-line prefer-const
234-
let { input, output, ignore = [], glob } = asset;
234+
let { input, output = '', ignore = [], glob } = asset;
235235
input = path.resolve(root, input).replace(/\\/g, '/');
236236
input = input.endsWith('/') ? input : input + '/';
237237
output = output.endsWith('/') ? output : output + '/';

0 commit comments

Comments
 (0)