I’ve been working on my project for a while using npm run dev which works, but when using npm run build, I started getting some errors that seemed to be related to the folder structure being broken. So, because…
- …these seemed impossible to debug from a minimized js file, and
- I’d like to have an index.php instead of index.html, which I can’t test in dev mode since vite doesn’t seem to support php
…I reworked my project to work statically on xammp. I ended up having to replace the import statements from from 'three, etc. to use the explicit path like this:
import * as Three from '../node_modules/three/build/three.module.min.js';
import CameraControls from '../node_modules/camera-controls/dist/camera-controls.module.min.js';
CameraControls.install( {THREE: Three });
import {EffectComposer} from '../node_modules/three/examples/jsm/postprocessing/EffectComposer.js';
import {RenderPass} from '../node_modules/three/examples/jsm/postprocessing/RenderPass.js';
import {ShaderPass} from '../node_modules/three/examples/jsm/postprocessing/ShaderPass.js';
and then go into each of those postprocessing files (including the ones they reference) and do the same for their ‘three’ references:
import {
Clock,
HalfFloatType,
NoBlending,
Vector2,
WebGLRenderTarget
} from '../../../build/three.module.min.js';
After that, I had to change some of my relative file paths because the root is being detected differently now that I’m not using npm run dev. These differences in path probably wouldn’t affect a pure three.js project, but mine uses php/mysql for database management as well as face-api.js (not from the npm installation because I had trouble working with the npm installation).
The result is that it works, and now I could probably delete most of the contents of the node_modules folder and be done with it, (maybe using a different minify tool once development is done) but I’d like your advice on how I should (have) approach(ed) this issue. The automatic culling of superfluous code done by npm run build seems like a useful feature, but it seemingly locks you into a npm-centric workflow. Maybe if I want to work statically like this, there’s a different install of three.js that I should use in the future instead of the npm install…?