Skip to content

Commit

Permalink
Angular: Fix missing architect properties (#9390)
Browse files Browse the repository at this point in the history
Angular: Fix missing architect properties
  • Loading branch information
shilman committed Jan 14, 2020
2 parents 98792f3 + f419b7f commit 287a3a7
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions app/angular/src/server/angular-cli_config.ts
Expand Up @@ -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;
}

Expand All @@ -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) {
Expand All @@ -90,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,
Expand All @@ -102,7 +123,10 @@ export function getAngularCliWebpackConfigOptions(dirToSearch: Path) {
optimization: {},
...projectOptions,
assets: normalizedAssets,
budgets
budgets,
scripts,
styles,
outputPath,
},
};
}
Expand Down

0 comments on commit 287a3a7

Please sign in to comment.