pmndrs / react-three-offscreen

📺 Offscreen worker canvas for react-three-fiber
https://offscreen.pmnd.rs
MIT License
456 stars 19 forks source link

Vite: works locally, but does not work in production #11

Open fax1ty opened 1 year ago

fax1ty commented 1 year ago

I got

Uncaught ReferenceError: document is not defined

on production, but everything is ok locally

vite.config.ts

import eslintPlugin from "@nabla/vite-plugin-eslint";
import react from "@vitejs/plugin-react";
import autoprefixer from "autoprefixer";
import dns from "dns";
import postcssLogical from "postcss-logical";
import { defineConfig } from "vite";
import svgr from "vite-plugin-svgr";

dns.setDefaultResultOrder("verbatim");

export default defineConfig({
  assetsInclude: ["**/*.glb", "**/*.gltf", "**/*.hdr", "**/*.riv"],
  server: {
    host: "localhost",
    port: 3000,
  },
  plugins: [react({ fastRefresh: false }), svgr(), eslintPlugin()],
  worker: { plugins: [react()] },
  esbuild: { jsx: "automatic" },
  css: {
    postcss: {
      plugins: [autoprefixer, postcssLogical],
    },
  },
});

also not working with @vitejs/plugin-react-swc

fax1ty commented 1 year ago

image The problem occurs because I use the Html component After building, styles are still inserted by injecting

fax1ty commented 1 year ago

Also, it doesn't work if something uses raf