https://github.com/kwonoj/webpack-loader-worker
https://github.com/kwonoj/webpack-loader-worker
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/kwonoj/webpack-loader-worker
- Owner: kwonoj
- License: mit
- Created: 2019-11-27T06:50:44.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-12-08T23:00:06.000Z (over 6 years ago)
- Last Synced: 2025-04-23T00:10:02.700Z (over 1 year ago)
- Language: TypeScript
- Size: 260 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://www.npmjs.com/package/webpack-loader-worker)
[](https://www.npmjs.com/package/webpack-loader-worker)
# webpack-loader-worker
`webpack-loader-worker` runs the following loaders in node.js `worker_threads` pool. It works as similar to [thread-loader](https://github.com/webpack-contrib/thread-loader), but only supports native node.js worker threads. (node.js >= 12. Version below 12 are untested)
## Install
```sh
npm install --save-dev webpack-loader-worker
```
## Usage
Put this loader in front of other loaders. The following loaders run in a worker pool. Loaders running in a thread pool are limited, does not have full access to webpack loader's context.
### Configuration examples
```ts
use: [
{
loader: "webpack-loader-worker",
options: {
// the number of spawned workers, defaults to (number of cpus - 1)
maxWorkers: 2,
logLevel: 'info' | 'verbose'
}
},
// your expensive loader (e.g babel-loader)
]
```
## Credits
While this module is **NOT** officially affiliated, it relies on a lot of prior art from [`thread-loader`](https://github.com/webpack-contrib/thread-loader). You may notice some similar logic, and it is expected.