Skip to content

Commit

Permalink
Fix fastboot-script assets with cutom root url
Browse files Browse the repository at this point in the history
When using custom rootURL specified in environment.js, the
fastboot-script is still having relative path to local dist path, not
containing rootURL path. The fastboot-script should not be ignored.
  • Loading branch information
xg-wang committed Aug 22, 2021
1 parent e6ff698 commit fc6fc24
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/fastboot/src/html-entrypoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ function htmlEntrypoint(appName, distPath, htmlPath) {
let relativeSrc = urlWithin(src, rootURL);
if (relativeSrc) {
scripts.push(path.join(distPath, relativeSrc));
} else if (element.tagName === 'FASTBOOT-SCRIPT') {
scripts.push(path.join(distPath, src));
}
}
if (element.tagName === 'FASTBOOT-SCRIPT') {
Expand Down
3 changes: 2 additions & 1 deletion packages/fastboot/test/html-entrypoint-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ describe('htmlEntrypoint', function() {
<html>
<meta name="my-app/config/environment" content="%7B%22rootURL%22%3A%22%2Fcustom-root-url%2F%22%7D" >
<body>
<fastboot-script src="foo.js"></fastboot-script>
<script src="/custom-root-url/bar.js"></script>
</body>
</html>
Expand All @@ -259,6 +260,6 @@ describe('htmlEntrypoint', function() {
fixturify.writeSync(tmpLocation, project);

let { scripts } = htmlEntrypoint('my-app', tmpLocation, 'index.html');
expect(scripts).to.deep.equal([`${tmpLocation}/bar.js`]);
expect(scripts).to.deep.equal([`${tmpLocation}/foo.js`, `${tmpLocation}/bar.js`]);
});
});

0 comments on commit fc6fc24

Please sign in to comment.