@@ -27,9 +27,9 @@ import {
2727} from '../utility/ast-utils' ;
2828import { applyToUpdateRecorder } from '../utility/change' ;
2929import { getAppModulePath , isStandaloneApp } from '../utility/ng-ast-utils' ;
30+ import { isUsingApplicationBuilder , targetBuildNotFoundError } from '../utility/project-targets' ;
3031import { findBootstrapApplicationCall , getMainFilePath } from '../utility/standalone/util' ;
31- import { getWorkspace , updateWorkspace } from '../utility/workspace' ;
32- import { Builders } from '../utility/workspace-models' ;
32+ import { getWorkspace } from '../utility/workspace' ;
3333import { Schema as AppShellOptions } from './schema' ;
3434
3535const APP_SHELL_ROUTE = 'shell' ;
@@ -156,29 +156,6 @@ function getMetadataProperty(metadata: ts.Node, propertyName: string): ts.Proper
156156return property ;
157157}
158158
159- function addAppShellConfigToWorkspace ( options :AppShellOptions ) :Rule {
160- return updateWorkspace ( ( workspace ) => {
161- const project = workspace . projects . get ( options . project ) ;
162- if ( ! project ) {
163- return ;
164- }
165- const buildTarget = project . targets . get ( 'build' ) ;
166- if (
167- buildTarget ?. builder === Builders . Application ||
168- buildTarget ?. builder === Builders . BuildApplication
169- ) {
170- // Application builder configuration.
171- const prodConfig = buildTarget . configurations ?. production ;
172- if ( ! prodConfig ) {
173- throw new SchematicsException (
174- `A "production" configuration is not defined for the "build" builder.` ,
175- ) ;
176- }
177- prodConfig . appShell = true ;
178- }
179- } ) ;
180- }
181-
182159function addServerRoutes ( options :AppShellOptions ) :Rule {
183160return async ( host :Tree ) => {
184161// The workspace gets updated so this needs to be reloaded
@@ -359,17 +336,21 @@ export default function (options: AppShellOptions): Rule {
359336const browserEntryPoint = await getMainFilePath ( tree , options . project ) ;
360337const isStandalone = isStandaloneApp ( tree , browserEntryPoint ) ;
361338
339+ const workspace = await getWorkspace ( tree ) ;
340+ const project = workspace . projects . get ( options . project ) ;
341+ if ( ! project ) {
342+ throw targetBuildNotFoundError ( ) ;
343+ }
344+
362345return chain ( [
363346validateProject ( browserEntryPoint ) ,
364347schematic ( 'server' , options ) ,
365- ...( options . serverRouting
348+ ...( isUsingApplicationBuilder ( project )
366349 ?[ noop ( ) ]
367350 :isStandalone
368351 ?[ addStandaloneServerRoute ( options ) ]
369352 :[ addServerRoutes ( options ) ] ) ,
370- options . serverRouting
371- ?addServerRoutingConfig ( options , isStandalone )
372- :addAppShellConfigToWorkspace ( options ) ,
353+ addServerRoutingConfig ( options , isStandalone ) ,
373354schematic ( 'component' , {
374355name :'app-shell' ,
375356module :'app.module.server.ts' ,