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 {useMainEntity} from '@/react/context/main-entity.js';
import Emitter from './emitter.jsx'; import Emitter from './emitter.jsx';
import Light from './light.jsx'; // import Light from './light.jsx';
import Sprite from './sprite.jsx'; import Sprite from './sprite.jsx';
function Aabb({color, width = 0.5, x0, y0, x1, y1, ...rest}) { function Aabb({color, width = 0.5, x0, y0, x1, y1, ...rest}) {

View File

@ -1,4 +1,5 @@
import {Group, Layer} from '@pixi/layers'; import {Group, Layer} from '@pixi/layers';
import * as Lights from '@pixi/lights';
class LightLayer extends Layer { class LightLayer extends Layer {
$$diffuseTexture; $$diffuseTexture;
@ -42,22 +43,16 @@ class DeferredLighting {
export const deferredLighting = new DeferredLighting(); export const deferredLighting = new DeferredLighting();
let AmbientLight, PointLight; export class AmbientLight extends Lights.AmbientLight {
if ('undefined' !== typeof window) {
const Lights = await import('@pixi/lights');
AmbientLight = class AmbientLight extends Lights.AmbientLight {
constructor(...args) { constructor(...args) {
super(...args); super(...args);
this.parentGroup = deferredLighting.lightGroup; this.parentGroup = deferredLighting.lightGroup;
} }
}
PointLight = class PointLight extends Lights.PointLight {
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({ const remixHandler = createRequestHandler({
build: async () => { build: async () => {
// patch pixi server context
import('./app/server/pixi-context.js');
const ssr = await ( const ssr = await (
viteDevServer viteDevServer
? viteDevServer.ssrLoadModule('virtual:remix/server-build') ? viteDevServer.ssrLoadModule('virtual:remix/server-build')

View File

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