question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to output .html to disk using Webpack-dev-server and HTML-webpack-plugin?

See original GitHub issue

I use webpack and html-webpack-plugin to update my index.html file with the generated script bundle, such as bundle.[hash].js.

Then I have to run webpack-dev-server so I can load that bundle into memory and take advantage of Hot Module Replacement.

This makes the code compile twice.

However, what I would like is for webpack-dev-server to also be able to update the index.html file with the new bundle.[hash].js, because now I have to run webpack followed by webpack-dev-sever. It seems weird to compile twice.

Again, the only reason I run webpack is to get my index.html file updated with the new hash of the bundle. If I could get webpack-dev-server to output an updated index.html to disk, then I could drop the webpack command altogether.

Is this possible? If so, what would the webpack config change be? My webpack config is very long so I didnt think it would help to post it here.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
genshinwcommented, Apr 17, 2018

You can try to use ‘html-webpack-harddisk-plugin’ to output the html to disk

1reaction
leosjcommented, Mar 16, 2018

compiler.outputFileSystem.readFileSync(compiler.outputPath+‘/index.html’);

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to output .html to disk using Webpack-dev-server and ...
I think this is exactly what you need: https://github.com/jantimon/html-webpack-harddisk-plugin. webpack-dev-server saves the updated HTML ...
Read more >
Output Management - webpack
Let's fix that with the HtmlWebpackPlugin . Setting up HtmlWebpackPlugin. First install the plugin and adjust the webpack.config.js file: npm ...
Read more >
html-webpack-plugin - npm
Start using html-webpack-plugin in your project by running `npm i ... write to disk the html file, useful when webpack-dev-server / HMR are ......
Read more >
html-webpack-harddisk-plugin-wv4 - npm package - Snyk
Write html files to hard disk even when using the webpack dev server or middleware For more information about how to use this...
Read more >
Webpack (3): How to Use Plugins and Build Local Servers
HtmlWebpackPlugin can automatically generate an index.html with bundle.js into the ... and then it is output to disk when the packing command is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found