Skip to content

Commit

Permalink
[#264] Adapt fixWebpackChunksIssue for CRAv2
Browse files Browse the repository at this point in the history
  • Loading branch information
stereobooster committed Oct 5, 2018
1 parent 98f44c8 commit 8e81fb9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const defaultOptions = {
},
sourceMaps: true,
//# workarounds
// TODO: use false, CRAv2 and CRAv1 (instead of true)
fixWebpackChunksIssue: true,
removeBlobs: true,
fixInsertRule: true,
Expand Down Expand Up @@ -361,7 +362,8 @@ const fixWebpackChunksIssue = ({
page,
basePath,
http2PushManifest,
inlineCss
inlineCss,
crav2
}) => {
return page.evaluate(
(basePath, http2PushManifest, inlineCss) => {
Expand Down Expand Up @@ -407,7 +409,7 @@ const fixWebpackChunksIssue = ({
for (let i = chunkScripts.length - 1; i >= 0; --i) {
const x = chunkScripts[i];
if (x.parentElement && mainScript.parentNode) {
x.parentElement.removeChild(x);
if (!crav2) x.parentElement.removeChild(x);
createLink(x);
}
}
Expand Down Expand Up @@ -609,7 +611,8 @@ const run = async (userOptions, { fs } = { fs: nativeFs }) => {
page,
basePath,
http2PushManifest,
inlineCss: options.inlineCss
inlineCss: options.inlineCss,
crav2: options.fixWebpackChunksIssue === 'CRAv2'
});
}
if (options.asyncScriptTags) await asyncScriptTags({ page });
Expand Down

0 comments on commit 8e81fb9

Please sign in to comment.