File tree Expand file tree Collapse file tree 2 files changed +10
-11
lines changed Expand file tree Collapse file tree 2 files changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -55,9 +55,9 @@ function updateIndexFile(options: PwaOptions): Rule {
55
55
const workspace = getWorkspace ( host ) ;
56
56
const project = workspace . projects [ options . project as string ] ;
57
57
let path : string ;
58
- if ( project && project . architect && project . architect . build &&
59
- project . architect . build . options . index ) {
60
- path = project . architect . build . options . index ;
58
+ const projectTargets = project . targets || project . architect ;
59
+ if ( project && projectTargets && projectTargets . build && projectTargets . build . options . index ) {
60
+ path = projectTargets . build . options . index ;
61
61
} else {
62
62
throw new SchematicsException ( 'Could not find index file for the project' ) ;
63
63
}
@@ -115,15 +115,14 @@ function addManifestToAssetsConfig(options: PwaOptions) {
115
115
116
116
const assetEntry = join ( normalize ( project . root ) , 'src' , 'manifest.json' ) ;
117
117
118
- if ( ! project . architect ) {
119
- throw new Error ( `Architect is not defined for this project.` ) ;
118
+ const projectTargets = project . targets || project . architect ;
119
+ if ( ! projectTargets ) {
120
+ throw new Error ( `Targets are not defined for this project.` ) ;
120
121
}
121
122
122
- const architect = project . architect ;
123
-
124
123
[ 'build' , 'test' ] . forEach ( ( target ) => {
125
124
126
- const applyTo = architect [ target ] . options ;
125
+ const applyTo = projectTargets [ target ] . options ;
127
126
const assets = applyTo . assets || ( applyTo . assets = [ ] ) ;
128
127
129
128
assets . push ( assetEntry ) ;
Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ describe('PWA Schematic', () => {
51
51
const tree = schematicRunner . runSchematic ( 'ng-add' , defaultOptions , appTree ) ;
52
52
const configText = tree . readContent ( '/angular.json' ) ;
53
53
const config = JSON . parse ( configText ) ;
54
- const swFlag = config . projects . bar . architect . build . configurations . production . serviceWorker ;
54
+ const swFlag = config . projects . bar . targets . build . configurations . production . serviceWorker ;
55
55
expect ( swFlag ) . toEqual ( true ) ;
56
56
} ) ;
57
57
@@ -101,9 +101,9 @@ describe('PWA Schematic', () => {
101
101
const tree = schematicRunner . runSchematic ( 'ng-add' , defaultOptions , appTree ) ;
102
102
const configText = tree . readContent ( '/angular.json' ) ;
103
103
const config = JSON . parse ( configText ) ;
104
- const architect = config . projects . bar . architect ;
104
+ const targets = config . projects . bar . targets ;
105
105
[ 'build' , 'test' ] . forEach ( ( target ) => {
106
- expect ( architect [ target ] . options . assets ) . toContain ( 'projects/bar/src/manifest.json' ) ;
106
+ expect ( targets [ target ] . options . assets ) . toContain ( 'projects/bar/src/manifest.json' ) ;
107
107
} ) ;
108
108
} ) ;
109
109
} ) ;
You can’t perform that action at this time.
0 commit comments