|
65 | 65 | import worker from 'workerize-loader?inline!./worker'
|
66 | 66 | ```
|
67 | 67 |
|
| 68 | +#### `name` |
| 69 | + |
| 70 | +Type: `String` |
| 71 | +Default: `[hash]` |
| 72 | + |
| 73 | +You can pass filename prefix for the compiled worker. Note, that `.worker` suffix will be added automatically |
| 74 | + |
| 75 | +```js |
| 76 | +// webpack.config.js |
| 77 | +{ |
| 78 | + loader: 'workerize-loader', |
| 79 | + options: { name: '[name].[contenthash:8]' } |
| 80 | +} |
| 81 | +``` |
| 82 | +or |
| 83 | +```js |
| 84 | +import worker from 'workerize-loader?{"name":"[name].[contenthash:8]"}!./worker' |
| 85 | +``` |
| 86 | + |
| 87 | +#### `publicPath` |
| 88 | + |
| 89 | +Type: `String` |
| 90 | +Default: based on `output.publicPath` |
| 91 | + |
| 92 | +You can pass `publicPath` to specify the public URL address of the output files |
| 93 | + |
| 94 | +```js |
| 95 | +// webpack.config.js |
| 96 | +{ |
| 97 | + loader: 'workerize-loader', |
| 98 | + options: { publicPath: '/static/' } |
| 99 | +} |
| 100 | +``` |
| 101 | +or |
| 102 | +```js |
| 103 | +import worker from 'workerize-loader?{"publicPath":"/static/"}!./worker' |
| 104 | +``` |
| 105 | + |
| 106 | +#### `ready` |
| 107 | + |
| 108 | +Type: `Boolean` |
| 109 | +Default: `false` |
| 110 | + |
| 111 | +You can pass `ready` to set up a wrapper around the `"ready"` event |
| 112 | + |
| 113 | +```js |
| 114 | +// webpack.config.js |
| 115 | +{ |
| 116 | + loader: 'workerize-loader', |
| 117 | + options: { ready: true } |
| 118 | +} |
| 119 | +``` |
| 120 | +or |
| 121 | +```js |
| 122 | +import worker from 'workerize-loader?ready!./worker' |
| 123 | + |
| 124 | +let instance = worker() // `new` is optional |
| 125 | + |
| 126 | +await instance.ready |
| 127 | +``` |
| 128 | + |
| 129 | +#### `fallback` |
| 130 | + |
| 131 | +Type: `Boolean` |
| 132 | +Default: `true` |
| 133 | + |
| 134 | +// TODO: document fallback option |
| 135 | + |
| 136 | +```js |
| 137 | +// webpack.config.js |
| 138 | +{ |
| 139 | + loader: 'workerize-loader', |
| 140 | + options: { fallback: false } |
| 141 | +} |
| 142 | +``` |
| 143 | +or |
| 144 | +```js |
| 145 | +import worker from 'workerize-loader?fallback=false!./worker' |
| 146 | +``` |
| 147 | + |
| 148 | +#### `import` |
| 149 | + |
| 150 | +Type: `Boolean` |
| 151 | +Default: `false` |
| 152 | + |
| 153 | +// TODO: document import option |
| 154 | + |
| 155 | +```js |
| 156 | +// webpack.config.js |
| 157 | +{ |
| 158 | + loader: 'workerize-loader', |
| 159 | + options: { import: true } |
| 160 | +} |
| 161 | +``` |
| 162 | +or |
| 163 | +```js |
| 164 | +import worker from 'workerize-loader?import!./worker' |
| 165 | +``` |
| 166 | + |
68 | 167 | ### About [Babel](https://babeljs.io/)
|
69 | 168 |
|
70 | 169 | If you're using [Babel](https://babeljs.io/) in your build, make sure you disabled commonJS transform. Otherwize, workerize-loader won't be able to retrieve the list of exported function from your worker script :
|
|
0 commit comments