Skip to content

wesmile2020/rollup-plugin-worker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rollup-plugin-worker

a rollup plugin for worker

Usage

Create a rollup.config.js and import the plugin:

const worker = require('rollup-plugin-worker');

module.exports = {
    plugins: [
        worker({
            prefix: 'worker!',
            plugins: [],
            uglify: false,
        }),
    ],
};

Options

  • prefix: string; default is 'worker!'
  • plugins: Plugin[]; Plugins needed in the process of processing worker
  • uglify: boolean; default is false; enable uglify?

Source Code

import Worker from 'worker!./workers/worker.js';

const worker = new Worker();

Use in typescript

Create a typing.d.ts in project and declare a module:

declare module 'worker!*' {
  class WebWorker extends Worker {
    constructor();
  }

  export default WebWorker;
}

About

a rollup plugin for worker

Resources

Stars

Watchers

Forks

Packages

No packages published