fix: production build

This commit is contained in:
cha0s 2024-07-21 11:04:06 -05:00
parent d0252bc9ff
commit ed8c07a88f
5 changed files with 30 additions and 17 deletions

View File

@ -5,7 +5,7 @@ import {useDebug} from '@/react/context/debug.js';
import {useMainEntity} from '@/react/context/main-entity.js';
import Emitter from './emitter.jsx';
import Light from './light.jsx';
// import Light from './light.jsx';
import Sprite from './sprite.jsx';
function Aabb({color, width = 0.5, x0, y0, x1, y1, ...rest}) {

View File

@ -1,4 +1,5 @@
import {Group, Layer} from '@pixi/layers';
import * as Lights from '@pixi/lights';
class LightLayer extends Layer {
$$diffuseTexture;
@ -42,22 +43,16 @@ class DeferredLighting {
export const deferredLighting = new DeferredLighting();
let AmbientLight, PointLight;
if ('undefined' !== typeof window) {
const Lights = await import('@pixi/lights');
AmbientLight = class AmbientLight extends Lights.AmbientLight {
constructor(...args) {
super(...args);
this.parentGroup = deferredLighting.lightGroup;
}
}
PointLight = class PointLight extends Lights.PointLight {
constructor(...args) {
super(...args);
this.parentGroup = deferredLighting.lightGroup;
}
export class AmbientLight extends Lights.AmbientLight {
constructor(...args) {
super(...args);
this.parentGroup = deferredLighting.lightGroup;
}
}
export {AmbientLight, PointLight};
export class PointLight extends Lights.PointLight {
constructor(...args) {
super(...args);
this.parentGroup = deferredLighting.lightGroup;
}
}

View File

@ -0,0 +1,8 @@
import {settings} from '@pixi/core';
settings.ADAPTER = {
...settings.ADAPTER,
createCanvas: () => ({
getContext: () => undefined,
}),
};

View File

@ -44,6 +44,8 @@ let websocketBuilt = false;
const remixHandler = createRequestHandler({
build: async () => {
// patch pixi server context
import('./app/server/pixi-context.js');
const ssr = await (
viteDevServer
? viteDevServer.ssrLoadModule('virtual:remix/server-build')

View File

@ -25,6 +25,11 @@ else {
}
export default defineConfig({
esbuild: {
supported: {
'top-level-await': true,
},
},
plugins,
resolve: {
alias: [
@ -41,4 +46,7 @@ export default defineConfig({
cert: readFileSync(`${cacheDirectory}/localhost.pem`),
},
},
worker: {
format: 'es',
},
});