Hi,
I am using webpack and I am trying to position the canvas. Too be honest, I don’t have a really good understanding of webpack, it was part of the template I used to start the game from. My game is in a file called ‘.src/index.js’ and the HTML template is a file called ‘index.html’.
The html file looks like:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>My Game</title>
</head>
<body style="text-align: center;">
</body>
<footer>
<!-- FOOTER INFORMATION HERE -->
</footer>
</html>
I want to put the canvas before the footer. I have tried using the “canvas” attribute in the game config and set it to document.getElementById(‘game’), game being the ID of a canvas element I tried inserting into the template. This didn’t work, I am guessing because the script is not loaded in time or because it is in a separate js file.
The webpack config file looks as below:
const webpack = require("webpack");
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
module.exports = {
mode: "development",
devtool: "eval-source-map",
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader"
}
},
{
test: [/\.vert$/, /\.frag$/],
use: "raw-loader"
},
{
test: /\.(gif|png|jpe?g|svg|xml)$/i,
use: "file-loader"
}
]
},
plugins: [
new CleanWebpackPlugin({
root: path.resolve(__dirname, "../")
}),
new webpack.DefinePlugin({
CANVAS_RENDERER: JSON.stringify(true),
WEBGL_RENDERER: JSON.stringify(true)
}),
new HtmlWebpackPlugin({
template: "./index.html"
})
]
};
I have looked online and can see things that relate to this, but to be honest, I don’t really understand.
Can someone help and point me in the right direction?