In my web app built with next.js, I am utilizing WebGL to render a 2D scene. Currently, I have my fragment and vertex shaders hardcoded as strings in my JavaScript:
var fragmentShaderSource = [
` #ifdef GL_ES`,
`precision highp float;`,
` #endif`,
``,
`uniform vec4 uGlobalColor;`,
``,
`void main() {`,
` gl_FragColor = uGlobalColor;`,
`}`,
].join("\n");
...
let shader = gl.createShader(type);
gl.shaderSource(shader, fragmentShaderSource);
gl.compileShader(shader);
However, I find this method to be inefficient and would prefer to use separate fragment.glsl and vertex.glsl files for development (with the compiled version still being a hardcoded string). I have heard about webpack, but as I am new to using next/webpack, I am unsure of what steps to take. The examples I have found are outdated, dating back to 6 years or more.