Created
May 21, 2018 22:53
-
-
Save engineersamuel/50bdc28ca19a7343e80535abeaaea9be to your computer and use it in GitHub Desktop.
Webpack event hook to rewrite index.html
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 EventHooksPlugin({ | |
'afterEmit': () => { | |
const hashedIndexHtml = glob.sync(`${paths.appBuild}/*.html`)[0]; | |
const hash = /index\.(.*?)\.html/.exec(hashedIndexHtml)[1]; | |
const webConfig = fs.readFileSync(`${paths.appBuild}/web.config`).toString(); | |
const result = webConfig.toString().replace(/index\.html/g, `index.${hash}.html`); | |
fs.writeFileSync(`${paths.appBuild}/web.config`, result); | |
} | |
}), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment