pmndrs / react-three-offscreen

📺 Offscreen worker canvas for react-three-fiber

Home Page:https://offscreen.pmnd.rs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Vite: works locally, but does not work in production

fax1ty opened this issue · comments

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

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

Also, it doesn't work if something uses raf