Skip to content Skip to sidebar Skip to footer

How To Load Web Worker Using Webpack's Worker Loader

I'm trying to load a web worker script into my React application by using webpack's worker loader. However, I get a module not found error. ERROR in ./src/index.js Module not f

Solution 1:

try the follwing:

importWorkerfrom'worker-loader!./file.worker.js';

You need to specify which loader(i.e. worker-loader) is going to load the worker explicitly.

Also, i dont think you need to configure the publicPath option.

Solution 2:

Try moving the file.worker.js into src. That's where you're looking for it with import Worker from "./file.worker";

Post a Comment for "How To Load Web Worker Using Webpack's Worker Loader"