@@ -23,6 +23,7 @@ import {
2323 applyWithSkipExisting ,
2424 isFramework ,
2525 getTsConfigContent ,
26+ TsConfig ,
2627} from '../../utils/utils' ;
2728import { CypressConfigureSchema } from '../cypress-project/cypress-project' ;
2829import { StorybookConfigureSchema } from './schema' ;
@@ -143,21 +144,43 @@ function createProjectStorybookDir(
143144 } ;
144145}
145146
146- function getTsConfigPath ( tree : Tree , projectName : string ) : string {
147+ function getTsConfigPath (
148+ tree : Tree ,
149+ projectName : string ,
150+ path ?: string
151+ ) : string {
147152 const { projectType } = getProjectConfig ( tree , projectName ) ;
148153 const projectPath = getProjectConfig ( tree , projectName ) . root ;
149154 return join (
150155 projectPath ,
151- projectType === 'application' ? 'tsconfig.app.json' : 'tsconfig.lib.json'
156+ path && path . length > 0
157+ ? path
158+ : projectType === 'application'
159+ ? 'tsconfig.app.json'
160+ : 'tsconfig.lib.json'
152161 ) ;
153162}
154163
155164function configureTsProjectConfig ( schema : StorybookConfigureSchema ) : Rule {
156165 const { name : projectName } = schema ;
157166
158167 return ( tree : Tree ) => {
159- const tsConfigPath = getTsConfigPath ( tree , projectName ) ;
160- const tsConfigContent = getTsConfigContent ( tree , tsConfigPath ) ;
168+ let tsConfigPath : string ;
169+ let tsConfigContent : TsConfig ;
170+
171+ try {
172+ tsConfigPath = getTsConfigPath ( tree , projectName ) ;
173+ tsConfigContent = getTsConfigContent ( tree , tsConfigPath ) ;
174+ } catch {
175+ /**
176+ * Custom app configurations
177+ * may contain a tsconfig.json
178+ * instead of a tsconfig.app.json.
179+ */
180+
181+ tsConfigPath = getTsConfigPath ( tree , projectName , 'tsconfig.json' ) ;
182+ tsConfigContent = getTsConfigContent ( tree , tsConfigPath ) ;
183+ }
161184
162185 tsConfigContent . exclude = [
163186 ...( tsConfigContent . exclude || [ ] ) ,
0 commit comments