Using three.js dependencies with webpack

Hi all, first post here.

I have been using requirejs for a long time when I had to develop big apps. Integrating three.js with this stack was no problem.

I am moving to webpack now, and everything is ok when importing three.js through npm. I use

import * as THREE from ‘three’;

And it works fine. But, what happens when I want to use an external script like OrbitControls or some postproduction. What would be the best way to import this scripts through webpack? Anyone has faced this issue before?

Thanks in advance

1 Like

There is a massive thread about this issue on Github that presents a few possible solutions to this. It’s discussing converting the examples to modules in general but ends up being quite focussed on Webpack.

Alternatively, I’ve found most examples need minimal changes to be uses as modules. Here’s OrbitControls

Yeah, I knew you could do an import in the file itself, but I was trying to keep these files clean in case someone updates libraries versions.

I will look into github discussion.