项目作者: SagiMedina

项目描述 :
worker loader module for webpack with static path
高级语言: JavaScript
项目地址: git://github.com/SagiMedina/worker-static-loader.git
创建时间: 2016-01-17T10:47:05Z
项目社区:https://github.com/SagiMedina/worker-static-loader

开源协议:

下载


worker loader for webpack with static path

Forked from https://github.com/webpack/worker-loader

Differences:
This loader will add the path of your static files folder when loading the worker js file

Installation

  1. npm i worker-static-loader

Usage

Documentation: Using loaders

Import the worker file:

  1. // main.js
  2. var MyWorker = require("worker-static-loader?{'staticPath':'##PATH_TO_STATIC_FOLDER##'}!./file.js");
  3. var worker = new MyWorker();
  4. worker.postMessage({a: 1});
  5. worker.onmessage = function(event) {...};
  6. worker.addEventListener("message", function(event) {...});

The worker file can import dependencies just like any other file:

  1. // file.js
  2. var _ = require('lodash')
  3. var o = {foo: 'foo'}
  4. _.has(o, 'foo') // true

You can even use ES6 modules if you have the babel-loader configured:

  1. // file.js
  2. import _ from 'lodash'
  3. let o = {foo: 'foo'}
  4. _.has(o, 'foo') // true

License

MIT (http://www.opensource.org/licenses/mit-license.php)