If anyone interested, here is a webpack-based config that excludes part of the shaders with externals
webpack.config.js
const excludeBabylonjs = [
/node_modules[\\/]@babylonjs[\\/]core[\\/]ShadersWGSL/, // Exclude WebGPU Shaders
// /node_modules[\\/]@babylonjs[\\/]core[\\/]Shaders/, // Exclude WebGL Shaders
// Add more here
];
module.exports = {
externals: function (context, request, callback) {
const absPath = path.join(context, request);
const relPath = path.relative(__dirname, absPath);
for (let i = 0, length = excludeBabylonjs.length; i < length; i++) {
if (excludeBabylonjs[i].test(relPath)) {
callback(null, {
root: 'Object', // It should be safe since shader imports are side-effects only
});
return;
}
}
callback();
}
};