Skip to content

Commit 5f67bd9

Browse files
author
Sergey Astapov
committed
Make manifest in package.json respect outputPaths configuration in EmberApp; fixes #538
1 parent a2540bf commit 5f67bd9

4 files changed

Lines changed: 21 additions & 21 deletions

File tree

index.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,13 @@ module.exports = {
166166
registry: this._appRegistry
167167
});
168168

169-
let fileAppName = path.basename(this.app.options.outputPaths.app.js).split('.')[0];
169+
function stripLeadingSlash(filePath) {
170+
return filePath.replace(/^\//, '');
171+
}
172+
173+
let appFilePath = stripLeadingSlash(this.app.options.outputPaths.app.js);
170174
let finalFastbootTree = new Concat(processExtraTree, {
171-
outputFile: 'assets/' + fileAppName + '-fastboot.js'
175+
outputFile: appFilePath.replace(/\.js$/, '-fastboot.js')
172176
});
173177

174178
return finalFastbootTree;
@@ -206,8 +210,8 @@ module.exports = {
206210
/**
207211
* Need to handroll our own clone algorithm since JSON.stringy changes regex
208212
* to empty objects which breaks hostWhiteList property of fastboot.
209-
*
210-
* @param {Object} config
213+
*
214+
* @param {Object} config
211215
*/
212216
_cloneConfigObject(config) {
213217
if (config === null || typeof config !== 'object') {

lib/broccoli/fastboot-config.js

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,13 @@ module.exports = class FastBootConfig extends Plugin {
174174
}
175175

176176
buildManifest() {
177-
let appFilePath = 'assets/' + path.basename(this.outputPaths.app.js);
178-
let appFileName = appFilePath.split('.')[0];
179-
let appFastbootFilePath = appFileName + '-fastboot.js';
180-
let vendorFilePath = 'assets/' + path.basename(this.outputPaths.vendor.js);
177+
function stripLeadingSlash(filePath) {
178+
return filePath.replace(/^\//, '');
179+
}
180+
181+
let appFilePath = stripLeadingSlash(this.outputPaths.app.js);
182+
let appFastbootFilePath = appFilePath.replace(/\.js$/, '') + '-fastboot.js';
183+
let vendorFilePath = stripLeadingSlash(this.outputPaths.vendor.js);
181184

182185
let manifest = {
183186
appFiles: [appFilePath, appFastbootFilePath],
@@ -197,7 +200,6 @@ module.exports = class FastBootConfig extends Plugin {
197200
// update the app files array with fingerprinted files
198201
let rewrittenAppFiles = manifest['appFiles'].map(file => rewrittenAssets.assets[file] || file);
199202
manifest['appFiles'] = rewrittenAppFiles;
200-
201203
}
202204

203205
this.manifest = manifest;
@@ -265,12 +267,3 @@ function getDependencyVersion(pkg, dep) {
265267

266268
return pkg.dependencies[dep];
267269
}
268-
269-
function assetToFastboot(key) {
270-
let parts = key.split('/');
271-
let dir = parts[0];
272-
if (dir === 'assets') {
273-
parts[0] = 'fastboot';
274-
}
275-
return parts.join('/');
276-
}

test/fixtures/customized-outputpaths/ember-cli-build.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ module.exports = function(defaults) {
88
app: {
99
html: 'index.html',
1010
css: {
11-
'app': '/assets/app.css',
11+
'app': '/some-assets/path/app.css',
1212
},
13-
js: '/assets/app.js'
13+
js: '/some-assets/path/app-file.js'
1414
},
1515
vendor: {
16-
js: '/assets/lib.js'
16+
js: '/some-assets/path/lib.js'
1717
}
1818
}
1919
});

test/package-json-test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,13 @@ describe('generating package.json', function() {
237237
let pkg = fs.readJsonSync(customApp.filePath('/dist/package.json'));
238238
let manifest = pkg.fastboot.manifest;
239239

240+
expect(manifest.appFiles).to.include('some-assets/path/app-file.js');
240241
manifest.appFiles.forEach(function(file) {
241242
expect(p(file)).to.be.a.file();
242243
});
243244
expect(p(manifest.htmlFile)).to.be.a.file();
245+
246+
expect(manifest.vendorFiles).to.include('some-assets/path/lib.js');
244247
manifest.vendorFiles.forEach(function(file) {
245248
expect(p(file)).to.be.a.file();
246249
});

0 commit comments

Comments
 (0)