You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<palign="center">Automatically bundle & compile Web Workers within Webpack.</p>
1
+
# Optimize Plugin for Webpack
6
2
3
+
Optimize your code for modern browsers while still supporting the other 10%, increasing your build performance, reducing bundle size and improving output quality.
7
4
8
-
### Features
9
-
10
-
Automatically compiles modules loaded in Web Workers:
In most cases, no options are necessary to use WorkerPlugin.
68
-
69
-
### `globalObject`
70
-
71
-
WorkerPlugin will warn you if your Webpack configuration has `output.globalObject` set to `window`, since doing so breaks Hot Module Replacement in web workers.
72
-
73
-
If you're not using HMR and want to disable this warning, pass `globalObject:false`:
74
-
75
-
```js
76
-
newWorkerPlugin({
77
-
// disable warnings about "window" breaking HMR:
78
-
globalObject:false
79
-
})
80
-
```
81
-
82
-
To configure the value of `output.globalObject` for WorkerPlugin's internal Webpack Compiler, set `globalObject` to any String:
83
-
84
-
```js
85
-
newWorkerPlugin({
86
-
// use "self" as the global object when receiving hot updates.
87
-
globalObject:'self'// <-- this is the default value
88
-
})
89
-
```
90
-
91
-
### `plugins`
92
-
93
-
By default, `WorkerPlugin` doesn't run any of your configured Webpack plugins when bundling worker code - this avoids running things like `html-webpack-plugin` twice. For cases where it's necessary to apply a plugin to Worker code, use the `plugins` option.
7
+
### Features
94
8
95
-
Here you can specify the names of plugins to "copy" from your existing Webpack configuration, or provide specific plugins to apply only to worker code:
9
+
- Much faster than your current Webpack setup
10
+
- Transparently optimizes all of your code
11
+
- Automatically optimizes all of your dependencies
12
+
- Compiles bundles for modern browsers (90%) and legacy browsers (10%)
13
+
- Removes unnecessary polyfills, even when inlined into dependencies
14
+
- Compiles a highly-optimized dedicated polyfills bundle
96
15
97
16
```js
98
-
module.exports= {
99
-
<...>
100
-
plugins: [
101
-
// an example of a plugin already being used:
102
-
newSomeExistingPlugin({ <...> }),
103
-
104
-
newWorkerPlugin({
105
-
plugins: [
106
-
// A string here will copy the named plugin from your configuration:
107
-
'SomeExistingPlugin',
108
-
109
-
// Or you can specify a plugin directly, only applied to Worker code:
0 commit comments