Created
August 20, 2018 12:46
-
-
Save MilosRasic/f947d2c4a6d2e42403a86f525cbffafa to your computer and use it in GitHub Desktop.
GGS GenerateAssetPlugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new GenerateAssetPlugin({ | |
filename: 'index.html', | |
fn: (compilation, cb) => { | |
var appHash = compilation.hash; | |
if (options.lazyLoadable) { | |
var oldHashHtmlMatch = indexHtml.match(new RegExp(chunkName + ':"(\\w{' + appHash.length + '})"')); | |
var newIndexHtml = indexHtml.replace(oldHashHtmlMatch[1], appHash); | |
var vendorOldHashHtmlMatch = indexHtml.match( | |
new RegExp('"' + chunkName + '.vendor":"(\\w{' + appHash.length + '})"') | |
); | |
if (vendorOldHashHtmlMatch && vendorOldHashHtmlMatch[1]) { | |
newIndexHtml = newIndexHtml.replace(vendorOldHashHtmlMatch[1], appHash); | |
} | |
cb(null, newIndexHtml); | |
} else { | |
var oldHashHtmlMatch = indexHtml.match( | |
new RegExp('src="(' + chunkName + '\\.\\w{' + appHash.length + '})') | |
); | |
cb(null, indexHtml.replace(new RegExp(oldHashHtmlMatch[1], 'g'), chunkName + '.' + appHash)); | |
} | |
}, | |
}), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment