@@ -85,87 +85,78 @@ function updateApplicationBuilderWorkspaceConfigRule(
85
85
projectRoot : string ,
86
86
options : AddServerOptions ,
87
87
) : Rule {
88
- return ( ) => {
89
- return updateWorkspace ( ( workspace ) => {
90
- const buildTarget = workspace . projects . get ( options . project ) ?. targets . get ( 'build' ) ;
91
- if ( ! buildTarget ) {
92
- return ;
93
- }
94
-
95
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
96
- const prodConfig = buildTarget . configurations ?. production as Record < string , any > ;
97
- if ( ! prodConfig ) {
98
- throw new SchematicsException (
99
- `A "production" configuration is not defined for the "build" builder.` ,
100
- ) ;
101
- }
88
+ return updateWorkspace ( ( workspace ) => {
89
+ const buildTarget = workspace . projects . get ( options . project ) ?. targets . get ( 'build' ) ;
90
+ if ( ! buildTarget ) {
91
+ return ;
92
+ }
102
93
103
- prodConfig . prerender = true ;
104
- prodConfig . ssr = join ( normalize ( projectRoot ) , 'server.ts' ) ;
105
- } ) ;
106
- } ;
94
+ buildTarget . options = {
95
+ ...buildTarget . options ,
96
+ prerender : true ,
97
+ ssr : join ( normalize ( projectRoot ) , 'server.ts' ) ,
98
+ } ;
99
+ } ) ;
107
100
}
108
101
109
102
function updateWebpackBuilderWorkspaceConfigRule ( options : AddServerOptions ) : Rule {
110
- return ( ) => {
111
- return updateWorkspace ( ( workspace ) => {
112
- const projectName = options . project ;
113
- const project = workspace . projects . get ( projectName ) ;
114
- if ( ! project ) {
115
- return ;
116
- }
103
+ return updateWorkspace ( ( workspace ) => {
104
+ const projectName = options . project ;
105
+ const project = workspace . projects . get ( projectName ) ;
106
+ if ( ! project ) {
107
+ return ;
108
+ }
117
109
118
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
119
- const serverTarget = project . targets . get ( 'server' ) ! ;
120
- ( serverTarget . options ??= { } ) . main = join ( normalize ( project . root ) , 'server.ts' ) ;
110
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
111
+ const serverTarget = project . targets . get ( 'server' ) ! ;
112
+ ( serverTarget . options ??= { } ) . main = join ( normalize ( project . root ) , 'server.ts' ) ;
121
113
122
- const serveSSRTarget = project . targets . get ( SERVE_SSR_TARGET_NAME ) ;
123
- if ( serveSSRTarget ) {
124
- return ;
125
- }
114
+ const serveSSRTarget = project . targets . get ( SERVE_SSR_TARGET_NAME ) ;
115
+ if ( serveSSRTarget ) {
116
+ return ;
117
+ }
126
118
127
- project . targets . add ( {
128
- name : SERVE_SSR_TARGET_NAME ,
129
- builder : '@angular-devkit/build-angular:ssr-dev-server' ,
130
- defaultConfiguration : 'development' ,
131
- options : { } ,
132
- configurations : {
133
- development : {
134
- browserTarget : `${ projectName } :build:development` ,
135
- serverTarget : `${ projectName } :server:development` ,
136
- } ,
137
- production : {
138
- browserTarget : `${ projectName } :build:production` ,
139
- serverTarget : `${ projectName } :server:production` ,
140
- } ,
119
+ project . targets . add ( {
120
+ name : SERVE_SSR_TARGET_NAME ,
121
+ builder : '@angular-devkit/build-angular:ssr-dev-server' ,
122
+ defaultConfiguration : 'development' ,
123
+ options : { } ,
124
+ configurations : {
125
+ development : {
126
+ browserTarget : `${ projectName } :build:development` ,
127
+ serverTarget : `${ projectName } :server:development` ,
141
128
} ,
142
- } ) ;
129
+ production : {
130
+ browserTarget : `${ projectName } :build:production` ,
131
+ serverTarget : `${ projectName } :server:production` ,
132
+ } ,
133
+ } ,
134
+ } ) ;
143
135
144
- const prerenderTarget = project . targets . get ( PRERENDER_TARGET_NAME ) ;
145
- if ( prerenderTarget ) {
146
- return ;
147
- }
136
+ const prerenderTarget = project . targets . get ( PRERENDER_TARGET_NAME ) ;
137
+ if ( prerenderTarget ) {
138
+ return ;
139
+ }
148
140
149
- project . targets . add ( {
150
- name : PRERENDER_TARGET_NAME ,
151
- builder : '@angular-devkit/build-angular:prerender' ,
152
- defaultConfiguration : 'production' ,
153
- options : {
154
- routes : [ '/' ] ,
141
+ project . targets . add ( {
142
+ name : PRERENDER_TARGET_NAME ,
143
+ builder : '@angular-devkit/build-angular:prerender' ,
144
+ defaultConfiguration : 'production' ,
145
+ options : {
146
+ routes : [ '/' ] ,
147
+ } ,
148
+ configurations : {
149
+ production : {
150
+ browserTarget : `${ projectName } :build:production` ,
151
+ serverTarget : `${ projectName } :server:production` ,
155
152
} ,
156
- configurations : {
157
- production : {
158
- browserTarget : `${ projectName } :build:production` ,
159
- serverTarget : `${ projectName } :server:production` ,
160
- } ,
161
- development : {
162
- browserTarget : `${ projectName } :build:development` ,
163
- serverTarget : `${ projectName } :server:development` ,
164
- } ,
153
+ development : {
154
+ browserTarget : `${ projectName } :build:development` ,
155
+ serverTarget : `${ projectName } :server:development` ,
165
156
} ,
166
- } ) ;
157
+ } ,
167
158
} ) ;
168
- } ;
159
+ } ) ;
169
160
}
170
161
171
162
function updateWebpackBuilderServerTsConfigRule ( options : AddServerOptions ) : Rule {
0 commit comments