44fbc24ccd
Resolves: https://github.com/zeit/next.js/issues/12545 This PR adds an example which show how to bundle and use WebWorkers in a next.js app. The issue mentions Typescript, but adding typescript to the example should be fairly simple by following the documentation and seems out of scope for a web-worker example.
15 lines
374 B
JavaScript
15 lines
374 B
JavaScript
const WorkerPlugin = require('worker-plugin')
|
|
|
|
module.exports = {
|
|
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
|
|
if (!isServer) {
|
|
config.plugins.push(
|
|
new WorkerPlugin({
|
|
// use "self" as the global object when receiving hot updates.
|
|
globalObject: 'self',
|
|
})
|
|
)
|
|
}
|
|
return config
|
|
},
|
|
}
|