From 7980eb656ceb17a34157a032e87ade84041e0186 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kai=20R=C3=B6der?= Date: Sat, 11 Jan 2020 09:56:11 +0100 Subject: [PATCH 1/2] chore(app/angular): add additional log outputs this should help improving the error reporting when a user has trouble using app/angular --- app/angular/src/server/angular-cli_config.ts | 26 +++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/app/angular/src/server/angular-cli_config.ts b/app/angular/src/server/angular-cli_config.ts index 746bbe4da465..f02dc983a9ee 100644 --- a/app/angular/src/server/angular-cli_config.ts +++ b/app/angular/src/server/angular-cli_config.ts @@ -50,6 +50,7 @@ export function getAngularCliConfig(dirToSearch: string) { const fname = path.join(dirToSearch, 'angular.json'); if (!fs.existsSync(fname)) { + logger.error(`Could not find angular.json using ${fname}`); return undefined; } @@ -67,9 +68,26 @@ export function getLeadingAngularCliProject(ngCliConfig: any) { throw new Error('angular.json must have projects entry.'); } - const fallbackProject = defaultProject && projects[defaultProject]; - const firstProject = projects[Object.keys(projects)[0]]; - return projects.storybook || fallbackProject || firstProject; + let projectName; + const firstProjectName = Object.keys(projects)[0]; + if (projects.storybook) { + projectName = 'storybook'; + } else if (defaultProject && projects[defaultProject]) { + projectName = defaultProject; + } else if (projects[firstProjectName]) { + projectName = firstProjectName; + } + + const project = projects[projectName]; + if (!project) { + logger.error(`Could not find angular project '${projectName}' in angular.json.`); + } else { + logger.info(`=> Using angular project '${projectName}' for configuring Storybook.`); + } + if (!project.architect.build) { + logger.error(`architect.build is not defined for project '${projectName}'.`); + } + return project; } export function getAngularCliWebpackConfigOptions(dirToSearch: Path) { @@ -102,7 +120,7 @@ export function getAngularCliWebpackConfigOptions(dirToSearch: Path) { optimization: {}, ...projectOptions, assets: normalizedAssets, - budgets + budgets, }, }; } From f419b7fa21aff07406bb3c8fe219b11ce50c81b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kai=20R=C3=B6der?= Date: Sat, 11 Jan 2020 10:03:58 +0100 Subject: [PATCH 2/2] fix(app/angular): add missing architect.build properties previously angular-devkit has thrown an error if they were missing fixes #9319 --- app/angular/src/server/angular-cli_config.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/angular/src/server/angular-cli_config.ts b/app/angular/src/server/angular-cli_config.ts index f02dc983a9ee..b027dd65ce61 100644 --- a/app/angular/src/server/angular-cli_config.ts +++ b/app/angular/src/server/angular-cli_config.ts @@ -108,6 +108,9 @@ export function getAngularCliWebpackConfigOptions(dirToSearch: Path) { const tsConfigPath = path.resolve(dirToSearch, projectOptions.tsConfig) as Path; const tsConfig = getTsConfigOptions(tsConfigPath); const budgets = projectOptions.budgets || []; + const scripts = projectOptions.scripts || []; + const outputPath = projectOptions.outputPath || 'dist/storybook-angular'; + const styles = projectOptions.styles || []; return { root: dirToSearch, @@ -121,6 +124,9 @@ export function getAngularCliWebpackConfigOptions(dirToSearch: Path) { ...projectOptions, assets: normalizedAssets, budgets, + scripts, + styles, + outputPath, }, }; }