configureWebpack: process.env.NODE_ENV === 'development'
? {
module: {
rules: [
{
test: /\.worker\.js$/,
use: {
loader: 'worker-loader',
options: {
inline: true
}
}
}
]
}
}
: {},
self.addEventListener('message', event => {
const data = event.data;
switch (data.cmd) {
case 'getInfo':
// eslint-disable-next-line no-case-declarations
const info = fetchInfo(data.token);
self.postMessage(info);
break;
default:
throw 'Unknown command'
}
});
import Worker from './custom.worker.js'
const worker = new Worker();
worker.postMessage({
cmd: 'getInfo',
data: {
token
},
})
/subpath/