Skip to content

Commit

Permalink
fix: fix broken output when injected into eval'ed string
Browse files Browse the repository at this point in the history
  • Loading branch information
birtles committed Jul 20, 2024
1 parent a24a5fe commit 9997a46
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,16 @@ async function injectManifest(
compilation,
options
);
const manifestString = stringify(sortedEntries);
let manifestString = stringify(sortedEntries);

// If the manifest is going to be injected into a string that is eval'ed, use
// single quotes to avoid breaking the string.
if (
typeof compilation.options.devtool === 'string' &&
compilation.options.devtool.startsWith('eval')
) {
manifestString = manifestString.replace(/"/g, `'`);
}

// Inject the manifest at the injectionPoint
const sourceMapAssetName = swAsset.info.related?.sourceMap;
Expand Down

0 comments on commit 9997a46

Please sign in to comment.