I'm new to bundling node.js apps with Webpack. I understand that hashes in filenames help with updating browser caches with new content.
Let's say I have the following HtmlWebpackPlugin config and express route:
// webpack.front-end.config.js
plugins: [
new HtmlWebpackPlugin({ minify, template: path.resolve('./src/index.html'), filename: 'index.[hash].html', chunks: ['home'] })
]
// server.js
app.get('/', (req, res) => {
res.sendFile('index.abc1234.html');
});
Then I change my content in index.html and it generates index.def3456.html.
How do I write my express route or change my webpack config so that I don't have to change the filename in the res.sendFile() call each time I change index.html content? Should I even have the hash in the index.html's filename? I'm aware I can put meta tags in index.html to avoid browser caching, but that seems like it would slow down performance.
There's no point in using the hash here. The client is not requesting the html file directly so it doesn't really matter what you name the file. All the client sees is the / endpoint.