Skip to content

Commit 30b9d5d

Browse files
authored
Merge pull request #376 from kratiahuja/update-readme
Update README with new `updateFastBootManifest` hook
2 parents 18f0157 + a3088ed commit 30b9d5d

1 file changed

Lines changed: 42 additions & 8 deletions

File tree

README.md

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,6 @@ ember install ember-cli-fastboot
3333
* `ember fastboot --serve-assets`
3434
* Visit your app at `http://localhost:3000`.
3535

36-
### With `ember-cli` version 2.12.0-beta.1 and above
37-
If your app is running ember-cli v2.12.0-beta.1+, you can just use `ember serve` instead of `ember fastboot --serve-assets` and visit at `http://localhost:4200/`.
38-
39-
Optionally you can even disable the fastboot serving at runtime using the `fastboot` query parameter. Example to turn off fastboot serving,
40-
visit your app at `http://localhost:4200/?fastboot=false`. If you want to turn on fastboot serving again, simply visit at `http://localhost:4200/?fastboot=true` or `http://localhost:4200/`.
41-
42-
You can even disable serving fastboot with `ember serve` using an environment flag: `FASTBOOT_DISABLED=true ember serve`. If you have disabled building fastboot assets using the same flag as described [here](https://github.com/ember-fastboot/ember-cli-fastboot#double-build-times-and-no-incremental-builds), remember to also disable serving fastboot assets when using `ember serve`.
43-
4436
You may be shocked to learn that minified code runs faster in Node than
4537
non-minified code, so you will probably want to run the production
4638
environment build for anything "serious."
@@ -57,6 +49,14 @@ ember fastboot --port 8088
5749

5850
See `ember help fastboot` for more.
5951

52+
### With `ember-cli` version 2.12.0-beta.1 and above
53+
If your app is running ember-cli v2.12.0-beta.1+, you can just use `ember serve` instead of `ember fastboot --serve-assets` and visit at `http://localhost:4200/`.
54+
55+
Optionally you can even disable the fastboot serving at runtime using the `fastboot` query parameter. Example to turn off fastboot serving,
56+
visit your app at `http://localhost:4200/?fastboot=false`. If you want to turn on fastboot serving again, simply visit at `http://localhost:4200/?fastboot=true` or `http://localhost:4200/`.
57+
58+
You can even disable serving fastboot with `ember serve` using an environment flag: `FASTBOOT_DISABLED=true ember serve`. If you have disabled building fastboot assets using the same flag as described [here](https://github.com/ember-fastboot/ember-cli-fastboot#double-build-times-and-no-incremental-builds), remember to also disable serving fastboot assets when using `ember serve`.
59+
6060
## Using Node/npm Dependencies
6161

6262
### Whitelisting Packages
@@ -365,6 +365,40 @@ if (!process.env.EMBER_CLI_FASTBOOT) {
365365
}
366366
```
367367

368+
*Note*: This is soon going to be deprecated. See [this issue](https://github.com/ember-fastboot/ember-cli-fastboot/issues/360).
369+
370+
## Loading additional assets in FastBoot environment
371+
372+
Often addons require to load libraries that are specific to the FastBoot environment and only need to be loaded on the server side. This can include loading
373+
libraries before or after the vendor file is loaded in the sandbox and/or before or after the app file is loaded in the sandbox. Since the FastBoot manifest defines
374+
an array of vendor and app files to load in the sandbox, an addon can define additional vendor/app files to load in the sandbox as well.
375+
376+
If your addon requires to load something in the sandbox: you can define the `updateFastBootManifest` hook from your addon (in `index.js`):
377+
378+
```js
379+
updateFastBootManifest(manifest) {
380+
/**
381+
* manifest is an object containing:
382+
* {
383+
* vendorFiles: [<path of the vendor file to load>, ...],
384+
* appFiles: [<path of the app file to load>, ...],
385+
* htmlFile: '<path of the base page that should be served by FastBoot>'
386+
* }
387+
*/
388+
389+
// This will load the foo.js before vendor.js is loaded in sandbox
390+
manifest.vendorFiles.unshift('<path to foo.js under dist>');
391+
// This will load bar.js after app.js is loaded in the sandbox
392+
manifest.appFiles.push('<path to bar.js under dist>');
393+
394+
// remember to return the updated manifest, otherwise your build will fail.
395+
return manifest;
396+
}
397+
```
398+
399+
*Note*: `process.env.EMBER_CLI_FASTBOOT` is soon going to be deprecated and [eventually removed](https://github.com/ember-fastboot/ember-cli-fastboot/issues/360).
400+
Therefore, if you are relying on this environment variable to import something in the fastboot environment, you should instead use `updateFastBootManifest` hook.
401+
368402

369403
## Known Limitations
370404

0 commit comments

Comments
 (0)