File tree 3 files changed +16
-4
lines changed
addon/ng2/blueprints/ng2/files 3 files changed +16
-4
lines changed Original file line number Diff line number Diff line change 17
17
< link rel ="{{rel}} " {{#if sizes}}sizes ="{{sizes}} " {{ /if}}href="{{href}} ">
18
18
{{/each}}
19
19
20
- <!-- Service worker support is disabled by default.
21
- Install the worker script and uncomment to enable.
22
- Only enable service workers in production.
20
+ {{#if environment.production}}
23
21
< script type ="text/javascript ">
24
22
if ( 'serviceWorker' in navigator ) {
25
23
navigator . serviceWorker . register ( '/worker.js' ) . catch ( function ( err ) {
26
24
console . log ( 'Error installing service worker: ' , err ) ;
27
25
} ) ;
28
26
}
29
27
</ script >
30
- -->
28
+ {{/if}}
31
29
< % } %>
32
30
</ head >
33
31
< body >
Original file line number Diff line number Diff line change 29
29
},
30
30
"devDependencies" : {<% if(isMobile) { %>
31
31
"@angular/platform-server" : " 2.0.0-rc.1" ,
32
+ "angular2-broccoli-prerender" : " ^0.11.0" ,
33
+ "angular2-service-worker" : " 0.1.11" ,
32
34
"angular2-universal" :" ^0.100.3" ,
33
35
"angular2-universal-polyfills" : " ^0.4.1" ,
34
36
"preboot" : " ^2.0.10" ,<% } %>
Original file line number Diff line number Diff line change @@ -159,6 +159,14 @@ class Angular2App extends BroccoliPlugin {
159
159
merged = this . _getBundleTree ( merged ) ;
160
160
}
161
161
162
+ if ( this . ngConfig . apps [ 0 ] . mobile ) {
163
+ var ServiceWorkerPlugin = require ( 'angular2-service-worker' ) . ServiceWorkerPlugin ;
164
+ var swTree = new ServiceWorkerPlugin ( merged ) ;
165
+ merged = BroccoliMergeTrees ( [ merged , swTree ] , {
166
+ overwrite : true
167
+ } ) ;
168
+ }
169
+
162
170
return new BroccoliFunnel ( merged , {
163
171
destDir : this . _destDir ,
164
172
overwrite : true
@@ -348,6 +356,10 @@ class Angular2App extends BroccoliPlugin {
348
356
var vendorNpmFiles = [
349
357
] ;
350
358
359
+ if ( this . ngConfig . apps [ 0 ] . mobile ) {
360
+ vendorNpmFiles . push ( 'angular2-service-worker/dist/worker.js' )
361
+ }
362
+
351
363
if ( this . _options . vendorNpmFiles ) {
352
364
vendorNpmFiles = vendorNpmFiles . concat ( this . _options . vendorNpmFiles ) ;
353
365
}
You can’t perform that action at this time.
0 commit comments