@@ -29,7 +29,9 @@ function getVersionChecker(context) {
29
29
return checker ;
30
30
}
31
31
32
-
32
+ function stripLeadingSlash ( filePath ) {
33
+ return filePath . replace ( / ^ \/ / , '' ) ;
34
+ }
33
35
34
36
/*
35
37
* Main entrypoint for the Ember CLI addon.
@@ -106,11 +108,6 @@ module.exports = {
106
108
return "<!-- EMBER_CLI_FASTBOOT_TITLE --><!-- EMBER_CLI_FASTBOOT_HEAD -->" ;
107
109
}
108
110
109
- if ( type === 'app-boot' ) {
110
- const isModuleUnification = ( typeof this . project . isModuleUnification === 'function' ) && this . project . isModuleUnification ( ) ;
111
- return fastbootAppModule ( config . modulePrefix , JSON . stringify ( config . APP || { } ) , isModuleUnification ) ;
112
- }
113
-
114
111
// if the fastboot addon is installed, we overwrite the config-module so that the config can be read
115
112
// from meta tag/directly for browser build and from Fastboot config for fastboot target.
116
113
if ( type === 'config-module' ) {
@@ -196,10 +193,6 @@ module.exports = {
196
193
registry : this . _appRegistry
197
194
} ) ;
198
195
199
- function stripLeadingSlash ( filePath ) {
200
- return filePath . replace ( / ^ \/ / , '' ) ;
201
- }
202
-
203
196
let appFilePath = stripLeadingSlash ( this . app . options . outputPaths . app . js ) ;
204
197
let finalFastbootTree = new Concat ( processExtraTree , {
205
198
outputFile : appFilePath . replace ( / \. j s $ / , '-fastboot.js' )
@@ -334,6 +327,8 @@ module.exports = {
334
327
} ,
335
328
336
329
postBuild ( result ) {
330
+ let appFilePath = stripLeadingSlash ( this . app . options . outputPaths . app . js ) ;
331
+ this . _appendAppBoot ( result . directory , appFilePath ) ;
337
332
if ( this . fastboot ) {
338
333
// should we reload fastboot if there are only css changes? Seems it maynot be needed.
339
334
// TODO(future): we can do a smarter reload here by running fs-tree-diff on files loaded
@@ -361,4 +356,14 @@ module.exports = {
361
356
362
357
return checker . for ( 'ember' , 'bower' ) ;
363
358
} ,
359
+
360
+ _appendAppBoot ( appDir , appFilePath ) {
361
+ let env = this . app . env ;
362
+ let config = this . project . config ( env ) ;
363
+ const isModuleUnification = ( typeof this . project . isModuleUnification === 'function' ) && this . project . isModuleUnification ( ) ;
364
+ const appBoot = fastbootAppModule ( config . modulePrefix , JSON . stringify ( config . APP || { } ) , isModuleUnification ) ;
365
+
366
+ appFilePath = path . resolve ( appDir , appFilePath ) ;
367
+ fs . appendFileSync ( appFilePath , appBoot ) ;
368
+ }
364
369
} ;
0 commit comments