@cirosantilli/_file/webpack/webpack/no-js-inject by Ciro Santilli 34 Updated 2024-12-15 +Created 1970-01-01
This example shows how you could manually include the
dist/index.js
that is output from webpack into your index.html
.This is generally not what you want to do, because what you actually want to do is to use a Js output name with a hash in it, so that browsers only need to refetch when the name changes.
And to do that, we have to let webpack dynamically inject that unpredictable hash as done in webpack/template with:
new HtmlWebpackPlugin({
filename: 'index.html',
// Inject the include to our hashed filename,
// since it is not deterministic due to the hash.
inject: true,
template: path.resolve(__dirname, 'index.html'),
}),