Bundle Shaders now produces an index.js

This commit is contained in:
Richard Davey 2023-02-16 16:13:22 +00:00
parent dd2efb6e5c
commit a93425ef0d
2 changed files with 99 additions and 1 deletions

View file

@ -5,7 +5,21 @@ let destdir = './src/renderer/webgl/shaders/';
let files = fs.readdirSync(srcdir);
files.forEach(function (file) {
let index = `/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2013-2023 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* @namespace Phaser.Renderer.WebGL.Shaders
*/
module.exports = {
`;
files.forEach(function (file, c) {
let shaderSource = fs.readFileSync(srcdir + file, 'utf8');
let type = file.substr(-4);
@ -49,4 +63,40 @@ files.forEach(function (file) {
});
let inc = file.substr(0, file.lastIndexOf('.'));
if (file.substr(-4) === 'frag')
{
inc = inc.concat('Frag');
}
else
{
inc = inc.concat('Vert');
}
index = index.concat(` ${inc}: require('./${shaderFilename}')`);
if (c < files.length - 1)
{
index = index.concat(',\n');
}
});
index = index.concat(`
};
`);
fs.writeFile(destdir + 'index.js', index, function (error) {
if (error)
{
throw error;
}
else
{
console.log('Index Saved');
}
});

View file

@ -0,0 +1,48 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2013-2023 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* @namespace Phaser.Renderer.WebGL.Shaders
*/
module.exports = {
AddBlendFrag: require('./AddBlend-frag.js'),
BitmapMaskFrag: require('./BitmapMask-frag.js'),
BitmapMaskVert: require('./BitmapMask-vert.js'),
ColorMatrixFrag: require('./ColorMatrix-frag.js'),
CopyFrag: require('./Copy-frag.js'),
FXBarrelFrag: require('./FXBarrel-frag.js'),
FXBloomFrag: require('./FXBloom-frag.js'),
FXBlurHighFrag: require('./FXBlurHigh-frag.js'),
FXBlurLowFrag: require('./FXBlurLow-frag.js'),
FXBlurMedFrag: require('./FXBlurMed-frag.js'),
FXBokehFrag: require('./FXBokeh-frag.js'),
FXCircleFrag: require('./FXCircle-frag.js'),
FXDisplacementFrag: require('./FXDisplacement-frag.js'),
FXGlowFrag: require('./FXGlow-frag.js'),
FXGradientFrag: require('./FXGradient-frag.js'),
FXPixelateFrag: require('./FXPixelate-frag.js'),
FXShadowFrag: require('./FXShadow-frag.js'),
FXShineFrag: require('./FXShine-frag.js'),
FXVignetteFrag: require('./FXVignette-frag.js'),
FXWipeFrag: require('./FXWipe-frag.js'),
LightFrag: require('./Light-frag.js'),
LinearBlendFrag: require('./LinearBlend-frag.js'),
MeshFrag: require('./Mesh-frag.js'),
MeshVert: require('./Mesh-vert.js'),
MobileFrag: require('./Mobile-frag.js'),
MobileVert: require('./Mobile-vert.js'),
MultiFrag: require('./Multi-frag.js'),
MultiVert: require('./Multi-vert.js'),
PointLightFrag: require('./PointLight-frag.js'),
PointLightVert: require('./PointLight-vert.js'),
PostFXFrag: require('./PostFX-frag.js'),
QuadVert: require('./Quad-vert.js'),
SingleFrag: require('./Single-frag.js'),
SingleVert: require('./Single-vert.js')
};