@@ -75,10 +75,37 @@ function modifyWorkspace(options: ApplicationOptions) {
7575 configureBuildConfigurations ( project ) ;
7676 configureTsLint ( project ) ;
7777 addTestOptions ( project ) ;
78- updateServeOptions ( project , options . name ) ;
78+ removeProductionConfiguration ( project ) ;
7979 } ) ;
8080}
8181
82+ /**
83+ * The default configuration is our production configuration.
84+ * The only configuration that needs to override this is the development configuration used in the serve option.
85+ */
86+ function removeProductionConfiguration ( project : ProjectDefinition ) {
87+ const buildTarget = project . targets . get ( 'build' ) ;
88+ const serveTarget = project . targets . get ( 'serve' ) ;
89+ if ( buildTarget === undefined ) {
90+ throw new SchematicsException ( "Build target missing (build)" ) ;
91+ }
92+ if ( buildTarget . configurations === undefined ) {
93+ throw new SchematicsException ( "Expected build options to be defined" ) ;
94+ }
95+ if ( buildTarget . configurations . production === undefined ) {
96+ throw new SchematicsException ( "Expected build options to be defined" ) ;
97+ }
98+ if ( serveTarget === undefined ) {
99+ throw new SchematicsException ( "Build target missing (serve)" ) ;
100+ }
101+ if ( serveTarget . configurations === undefined ) {
102+ throw new SchematicsException ( "Build target configurations missing (serve)" ) ;
103+ }
104+
105+ delete serveTarget . configurations . production ;
106+ delete buildTarget . configurations . production ;
107+ }
108+
82109function removeDuplicateStyle ( project : ProjectDefinition ) {
83110 const extensions = project . extensions ;
84111 const schematics = cloneDeep ( extensions . schematics ) as JsonObject ;
@@ -107,18 +134,6 @@ function addBuildOptions(project: ProjectDefinition) {
107134 buildTarget . options [ 'outputPath' ] = 'dist' ;
108135}
109136
110- function updateServeOptions ( project : ProjectDefinition , projectName : string ) {
111- const targets = project . targets ;
112- const serveTarget = targets . get ( 'serve' ) ;
113- if ( serveTarget === undefined ) {
114- throw new SchematicsException ( "Build target missing (serve)" ) ;
115- }
116- serveTarget . options = { } ;
117- serveTarget . options [ 'browserTarget' ] = projectName + ':build:serve' ;
118- delete serveTarget [ "configurations" ] ;
119- delete serveTarget [ "defaultConfiguration" ] ;
120- }
121-
122137function addTestOptions ( project : ProjectDefinition ) {
123138 const testTarget = project . targets . get ( 'test' ) ;
124139 if ( testTarget === undefined ) {
@@ -147,6 +162,7 @@ function moveBudgets(project: ProjectDefinition) {
147162 }
148163 const budgets = buildTarget . configurations . production . budgets ;
149164 buildTarget . options [ 'budgets' ] = cloneDeep ( budgets ) ;
165+ delete buildTarget . configurations . production . budgets ;
150166}
151167
152168function configureBuildConfigurations ( project : ProjectDefinition ) {
@@ -160,19 +176,14 @@ function configureBuildConfigurations(project: ProjectDefinition) {
160176 if ( buildTarget . configurations === undefined ) {
161177 throw new SchematicsException ( "Expected build configurations to be defined" ) ;
162178 }
163-
164- buildTarget . configurations = {
165- serve : {
166- buildOptimizer : false ,
167- optimization : false ,
168- extractLicenses : false ,
169- statsJson : false ,
170- sourceMap : true ,
171- vendorChunk : true ,
172- namedChunks : true
173- }
174- } ;
175- delete buildTarget [ 'defaultConfiguration' ] ;
179+ if ( buildTarget . configurations . development === undefined ) {
180+ throw new SchematicsException ( "Expected build configurations development to be defined" ) ;
181+ }
182+ buildTarget . configurations . development [ 'statsJson' ] = false ;
183+ delete buildTarget . configurations . development . vendorChunk ; // Already defaulted correctly in build options
184+ delete buildTarget . configurations . development . sourceMap ; // Already defaulted correctly in build options
185+ delete buildTarget . configurations . development . namedChunks ; // Already defaulted correctly in build options
186+ delete buildTarget . defaultConfiguration ; // There is no production configuration (the default is no configuration, only overrideable by the development configuration)
176187}
177188
178189function configureTsLint ( project : ProjectDefinition ) {
0 commit comments