Skip to content

Commit

Permalink
fix(ngx-build-modern): Take care of angular cli deployUrl setting for…
Browse files Browse the repository at this point in the history
… nomodule polyfill
  • Loading branch information
saschanowak committed Feb 11, 2019
1 parent 0d4b156 commit 19e2d3f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ngx-build-modern/src/modern-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export default {
post(builderConfig) {

const outputPath = builderConfig.options.outputPath;
const deployUrl = builderConfig.options.deployUrl;

const indexPath = path.join(
outputPath,
Expand All @@ -89,7 +90,7 @@ export default {

setNoModuleFlag(legacyScripts);
addModernElements(outputPath, indexDocument, anchorElement);
addPolyfill(outputPath, indexDocument, anchorElement);
addPolyfill(outputPath, deployUrl, indexDocument, anchorElement);

writeIndexHtml(indexPath, indexDocument);

Expand All @@ -112,11 +113,11 @@ function loadIndexHtml(indexPath: string) {
return indexDocument;
}

function addPolyfill(outputPath: string, indexDocument: HTMLDocument, anchorElement: HTMLScriptElement) {
function addPolyfill(outputPath: string, deployUrl: string, indexDocument: HTMLDocument, anchorElement: HTMLScriptElement) {
const polyfillPath = path.join(
outputPath, 'nomodule-polyfill.js');
const polyfillScript = indexDocument.createElement('script');
polyfillScript.src = 'nomodule-polyfill.js';
polyfillScript.src = `${deployUrl}nomodule-polyfill.js`;
anchorElement.parentElement.insertBefore(polyfillScript, anchorElement);
// Workaround for nomodule in Safari 10
// https://gist.github.com/samthor/64b114e4a4f539915a95b91ffd340acc
Expand Down

0 comments on commit 19e2d3f

Please sign in to comment.