use html webpack plugin to do cache busting (#71)

add a ?<hash of content> to index.js in index.html
This commit is contained in:
Romain Beaumont 2021-03-13 19:48:53 +01:00 committed by GitHub
commit 14f2a4cbec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 5 deletions

View file

@ -6,7 +6,7 @@
</head>
<body>
<div id="hotbar-wrapper">
<img id="hotbar-image" src="textures/1.16.4/gui/widgets.png"> <!--NOTE: DELETE THE PUBLIC HERE BEFORE MERGING! THIS IS FOR TESTING W/O WEBPACK !-->
<img id="hotbar-image" src="textures/1.16.4/gui/widgets.png">
<img id="hotbar-highlight" src="textures/1.16.4/gui/widgets.png">
<div id="hotbar-items-wrapper">
<img class="hotbar-item" id="hotbar-0" src="textures/1.16.4/blocks/stone.png">
@ -18,7 +18,6 @@
<img class="hotbar-item" id="hotbar-6" src="textures/1.16.4/items/netherite_pickaxe.png">
<img class="hotbar-item" id="hotbar-7" src="textures/1.16.4/items/netherite_axe.png">
<img class="hotbar-item" id="hotbar-8" src="textures/1.16.4/items/netherite_shovel.png">
<h1 style="color: gray;">test</h1>
</div>
</div>
@ -39,7 +38,5 @@
<h1 class="middle" id="loading-text">Waiting for JS load...</h1>
</div>
</div>
<script type="text/javascript" src="index.js"></script>
</body>
</html>

View file

@ -54,6 +54,7 @@
"copy-webpack-plugin": "^8.0.0",
"crypto-browserify": "^3.12.0",
"events": "^3.2.0",
"html-webpack-plugin": "^5.3.1",
"http-browserify": "^1.7.0",
"http-server": "^0.12.3",
"https-browserify": "^1.0.0",

View file

@ -1,6 +1,7 @@
const webpack = require('webpack')
const path = require('path')
const CopyPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
// https://webpack.js.org/guides/production/
const config = {
@ -40,6 +41,10 @@ const config = {
}
},
plugins: [
new HtmlWebpackPlugin({
template: 'index.html',
hash: true
}),
// fix "process is not defined" error:
new webpack.ProvidePlugin({
process: 'process/browser'
@ -53,7 +58,6 @@ const config = {
),
new CopyPlugin({
patterns: [
{ from: path.join(__dirname, '/index.html'), to: './index.html' },
{ from: path.join(__dirname, '/styles.css'), to: './styles.css' },
{ from: path.join(__dirname, '/node_modules/prismarine-viewer/public/blocksStates/'), to: './blocksStates/' },
{ from: path.join(__dirname, '/node_modules/prismarine-viewer/public/textures/'), to: './textures/' },