I use react-scripts, not webpack. How to do the configuration change to use worker-plugin?
I think I found the solution by adding
const WorkerPlugin = require('worker-plugin');
plugins:[
new WorkerPlugin({globalObject: 'self'}),
....]
into the node_modules/react-scripts/config/webpack.config.js file. Now seems like the worker.js can be bundled and automatically compiled. However I met the compiling error when compile the following worker.js file.
Line 2: Unexpected use of 'addEventListener' no-restricted-globals
in worker.js
import answer from './answer';
addEventListener('message',function(e){
console.log("WORKER data ",e.data);
postMessage("123 123 abc abc");
});
I use react-scripts, not webpack. How to do the configuration change to use worker-plugin? I think I found the solution by adding
into the node_modules/react-scripts/config/webpack.config.js file. Now seems like the worker.js can be bundled and automatically compiled. However I met the compiling error when compile the following worker.js file.
in worker.js
What am I missing here?
thanks