Skip to content

Commit ce68318

Browse files
committed
adding custom fastboot app
1 parent 85ed28d commit ce68318

5 files changed

Lines changed: 102 additions & 15 deletions

File tree

test-packages/custom-fastboot-app/config/environment.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ module.exports = function(environment) {
66
environment,
77
rootURL: '/',
88
locationType: 'auto',
9+
10+
fastboot: {
11+
htmlFile: 'custom-index.html'
12+
},
13+
914
EmberENV: {
1015
FEATURES: {
1116
// Here you can enable experimental features on an ember canary build

test-packages/custom-fastboot-app/ember-cli-build.js

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,13 @@ const EmberApp = require('ember-cli/lib/broccoli/ember-app');
44

55
module.exports = function(defaults) {
66
let app = new EmberApp(defaults, {
7-
// Add options here
7+
fingerprint: {
8+
prepend: 'https://totally-sick-cdn.example.com/',
9+
exclude: ['vendor.js', 'custom-fastboot-app.js'],
10+
generateAssetMap: true,
11+
assetMapPath: 'totally-customized-asset-map.json'
12+
}
813
});
914

10-
// Use `app.import` to add additional libraries to the generated
11-
// output files.
12-
//
13-
// If you need to use different assets in different
14-
// environments, specify an object as the first parameter. That
15-
// object's keys should be the environment name and the values
16-
// should be the asset to use in that environment.
17-
//
18-
// If the library that you are including contains AMD or ES6
19-
// modules that you would like to import into your application
20-
// please specify an object with the list of modules as keys
21-
// along with the exports of each module as its value.
22-
2315
return app.toTree();
2416
};

test-packages/custom-fastboot-app/package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"test": "tests"
1212
},
1313
"scripts": {
14-
"build": "ember build --environment=production",
14+
"build": "ember build",
15+
"build:prod": "ember build --environment=production",
1516
"lint": "npm-run-all --aggregate-output --continue-on-error --parallel lint:*",
1617
"lint:hbs": "ember-template-lint .",
1718
"lint:js": "eslint .",
@@ -25,11 +26,15 @@
2526
"@glimmer/tracking": "^1.0.0",
2627
"babel-eslint": "^10.1.0",
2728
"broccoli-asset-rev": "^3.0.0",
29+
"chai": "^4.2.0",
30+
"chai-fs": "^2.0.0",
31+
"chai-string": "^1.5.0",
2832
"ember-auto-import": "^1.5.3",
2933
"ember-cli": "~3.19.0",
3034
"ember-cli-app-version": "^3.2.0",
3135
"ember-cli-babel": "^7.20.5",
3236
"ember-cli-dependency-checker": "^3.2.0",
37+
"ember-cli-fastboot": "3.0.0-beta.2",
3338
"ember-cli-htmlbars": "^5.1.2",
3439
"ember-cli-inject-live-reload": "^2.0.2",
3540
"ember-cli-sri": "^2.1.1",
@@ -43,10 +48,12 @@
4348
"ember-resolver": "^8.0.0",
4449
"ember-source": "~3.19.0",
4550
"ember-template-lint": "^2.8.0",
51+
"ember-welcome-page": "^4.0.0",
4652
"eslint": "^7.1.0",
4753
"eslint-plugin-ember": "^8.6.0",
4854
"eslint-plugin-node": "^11.1.0",
4955
"loader.js": "^4.7.0",
56+
"mocha": "^8.0.1",
5057
"npm-run-all": "^4.1.5",
5158
"qunit-dom": "^1.2.0"
5259
},
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<title>custom index</title>
7+
<meta name="description" content="">
8+
<meta name="viewport" content="width=device-width, initial-scale=1">
9+
10+
<!-- EMBER_CLI_FASTBOOT_HEAD -->
11+
12+
<link rel="stylesheet" href="assets/vendor.css">
13+
<link rel="stylesheet" href="assets/custom-html-file.css">
14+
</head>
15+
<body>
16+
<!-- EMBER_CLI_FASTBOOT_BODY -->
17+
18+
<script src="assets/vendor.js"></script>
19+
<script src="assets/custom-html-file.js"></script>
20+
</body>
21+
</html>
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
"use strict";
2+
3+
const chai = require("chai");
4+
const expect = chai.expect;
5+
const fs = require("fs-extra");
6+
const execa = require("execa");
7+
8+
chai.use(require("chai-fs"));
9+
10+
describe("generating package.json", function () {
11+
this.timeout(300000);
12+
13+
describe('with customized fingerprinting options', function() {
14+
15+
before(async function () {
16+
await execa("yarn", ["build:prod"]);
17+
});
18+
19+
it("builds a package.json", async function () {
20+
expect("dist/totally-customized-asset-map.json").to.be.a.file();
21+
expect("dist/package.json").to.be.a.file();
22+
});
23+
24+
it('respects a custom asset map path and prepended URLs', function() {
25+
expect("dist/totally-customized-asset-map.json").to.be.a.file();
26+
let pkg = fs.readJSONSync("dist/package.json");
27+
let manifest = pkg.fastboot.manifest;
28+
29+
manifest.appFiles.forEach((file) => {
30+
expect(`dist/${file}`).to.be.a.file();
31+
});
32+
33+
expect(`dist/${manifest.htmlFile}`).to.be.a.file();
34+
35+
manifest.vendorFiles.forEach((file) => {
36+
expect(`dist/${file}`).to.be.a.file();
37+
});
38+
});
39+
40+
it('respects individual files being excluded from fingerprinting', function() {
41+
expect("dist/totally-customized-asset-map.json").to.be.a.file();
42+
43+
let pkg = fs.readJSONSync("dist/package.json");
44+
let manifest = pkg.fastboot.manifest;
45+
46+
// custom-fastboot-app is excluded from fingerprinting
47+
expect(manifest.appFiles).to.include('assets/custom-fastboot-app.js');
48+
// vendor.js is excluded from fingerprinting
49+
expect(manifest.vendorFiles).to.include('assets/vendor.js');
50+
});
51+
52+
describe('with custom htmlFile', function() {
53+
it('uses custom htmlFile in the manifest', function() {
54+
let pkg = fs.readJSONSync("dist/package.json");
55+
let manifest = pkg.fastboot.manifest;
56+
57+
expect(manifest.htmlFile).to.equal('custom-index.html');
58+
expect(`dist/${manifest.htmlFile}`).to.be.a.file();
59+
});
60+
});
61+
});
62+
});

0 commit comments

Comments
 (0)