a rollup plugin for worker
Create a rollup.config.js
and import the plugin:
const worker = require('rollup-plugin-worker');
module.exports = {
plugins: [
worker({
prefix: 'worker!',
plugins: [],
uglify: false,
}),
],
};
- prefix: string; default is 'worker!'
- plugins: Plugin[]; Plugins needed in the process of processing worker
- uglify: boolean; default is false; enable uglify?
import Worker from 'worker!./workers/worker.js';
const worker = new Worker();
Create a typing.d.ts
in project and declare a module:
declare module 'worker!*' {
class WebWorker extends Worker {
constructor();
}
export default WebWorker;
}