From fc6fc2431eb6069057371de9ffb08d7d90d3b0c5 Mon Sep 17 00:00:00 2001 From: Thomas Wang Date: Sat, 21 Aug 2021 23:18:21 -0700 Subject: [PATCH] Fix fastboot-script assets with cutom root url 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. --- packages/fastboot/src/html-entrypoint.js | 2 ++ packages/fastboot/test/html-entrypoint-test.js | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/fastboot/src/html-entrypoint.js b/packages/fastboot/src/html-entrypoint.js index 8e2a2213d..6bafc9e9c 100644 --- a/packages/fastboot/src/html-entrypoint.js +++ b/packages/fastboot/src/html-entrypoint.js @@ -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') { diff --git a/packages/fastboot/test/html-entrypoint-test.js b/packages/fastboot/test/html-entrypoint-test.js index df8030f67..c12286c65 100644 --- a/packages/fastboot/test/html-entrypoint-test.js +++ b/packages/fastboot/test/html-entrypoint-test.js @@ -250,6 +250,7 @@ describe('htmlEntrypoint', function() { + @@ -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`]); }); });