Skip to content

Commit a910fe9

Browse files
committed
fix(@schematics/angular): remove explicit outputPath option value from generated applications
The `outputPath` option now defaults to `dist/<project_name>` for applications. This removes the need to explicitly set the option within a newly generated project. The value removal also reduces the overall size of the `angular.json` configuration for new projects. Existing projects are not modified by this change.
1 parent eee6f3b commit a910fe9

File tree

6 files changed

+8
-9
lines changed

6 files changed

+8
-9
lines changed

packages/schematics/angular/application/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ function addAppToWorkspaceFile(
236236
builder: Builders.BuildApplication,
237237
defaultConfiguration: 'production',
238238
options: {
239-
outputPath: `dist/${folderName}`,
240239
index: `${sourceRoot}/index.html`,
241240
browser: `${sourceRoot}/main.ts`,
242241
polyfills: options.experimentalZoneless ? [] : ['zone.js'],

packages/schematics/angular/ssr/index.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,9 @@ async function getApplicationBuilderOutputPaths(
8181
throw new SchematicsException(`Cannot find 'options' for ${projectName} ${target} target.`);
8282
}
8383

84-
const { outputPath } = architectTarget.options;
85-
if (outputPath === null || outputPath === undefined) {
86-
throw new SchematicsException(
87-
`outputPath for ${projectName} ${target} target is undefined or null.`,
88-
);
89-
}
84+
let { outputPath } = architectTarget.options;
85+
// Use default if not explicitly specified
86+
outputPath ??= posix.join('dist', projectName);
9087

9188
const defaultDirs = {
9289
server: DEFAULT_SERVER_DIR,

packages/schematics/angular/ssr/index_spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ describe('SSR Schematic', () => {
118118
const build = config.projects['test-app'].architect.build;
119119

120120
build.options.outputPath = {
121-
base: build.options.outputPath,
121+
base: 'dist/test-app',
122122
browser: 'public',
123123
server: 'node-server',
124124
};
@@ -139,7 +139,7 @@ describe('SSR Schematic', () => {
139139
const build = config.projects['test-app'].architect.build;
140140

141141
build.options.outputPath = {
142-
base: build.options.outputPath,
142+
base: 'dist/test-app',
143143
browser: '',
144144
server: 'node-server',
145145
};

tests/legacy-cli/e2e/tests/build/jit-ngmodule.ts

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export default async function () {
2323
main: build.options.browser,
2424
browser: undefined,
2525
buildOptimizer: false,
26+
outputPath: 'dist/test-project-two',
2627
};
2728

2829
build.configurations.development = {

tests/legacy-cli/e2e/tests/build/rebuild-dot-dirname.ts

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export default async function () {
3333
...build.options,
3434
main: build.options.browser,
3535
browser: undefined,
36+
outputPath: 'dist/subdirectory-test-project',
3637
};
3738

3839
build.configurations.development = {

tests/legacy-cli/e2e/tests/build/relative-sourcemap.ts

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export default async function () {
1818
...build.options,
1919
main: build.options.browser,
2020
browser: undefined,
21+
outputPath: 'dist/secondary-project',
2122
};
2223

2324
build.configurations.development = {

0 commit comments

Comments
 (0)