Skip to content

Instantly share code, notes, and snippets.

@engineersamuel
Created May 21, 2018 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save engineersamuel/50bdc28ca19a7343e80535abeaaea9be to your computer and use it in GitHub Desktop.
Save engineersamuel/50bdc28ca19a7343e80535abeaaea9be to your computer and use it in GitHub Desktop.
Webpack event hook to rewrite index.html
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