( BUILD_CONFIG: BUILD_CONFIG_TYPE, config: CreateHTMLPluginConfig )
| 202 | }; |
| 203 | |
| 204 | export function createHTMLPlugins( |
| 205 | BUILD_CONFIG: BUILD_CONFIG_TYPE, |
| 206 | config: CreateHTMLPluginConfig |
| 207 | ): WebpackPluginInstance[] { |
| 208 | const publicPath = getPublicPath(BUILD_CONFIG); |
| 209 | const htmlPluginOptions = getHTMLPluginOptions(BUILD_CONFIG); |
| 210 | const selfhostPublicPath = config.selfhostPublicPath ?? '/'; |
| 211 | |
| 212 | const plugins: WebpackPluginInstance[] = []; |
| 213 | plugins.push( |
| 214 | new HTMLPlugin({ |
| 215 | ...htmlPluginOptions, |
| 216 | chunks: ['index'], |
| 217 | filename: config.filename, |
| 218 | publicPath, |
| 219 | meta: { |
| 220 | 'env:publicPath': publicPath, |
| 221 | }, |
| 222 | }) |
| 223 | ); |
| 224 | |
| 225 | if (BUILD_CONFIG.isElectron) { |
| 226 | plugins.push( |
| 227 | new HTMLPlugin({ |
| 228 | ...htmlPluginOptions, |
| 229 | chunks: ['shell'], |
| 230 | filename: 'shell.html', |
| 231 | publicPath, |
| 232 | meta: { |
| 233 | 'env:publicPath': publicPath, |
| 234 | }, |
| 235 | }), |
| 236 | new HTMLPlugin({ |
| 237 | ...htmlPluginOptions, |
| 238 | filename: 'popup.html', |
| 239 | chunks: ['popup'], |
| 240 | publicPath, |
| 241 | meta: { |
| 242 | 'env:publicPath': publicPath, |
| 243 | }, |
| 244 | }), |
| 245 | new HTMLPlugin({ |
| 246 | ...htmlPluginOptions, |
| 247 | filename: 'background-worker.html', |
| 248 | chunks: ['backgroundWorker'], |
| 249 | publicPath, |
| 250 | meta: { |
| 251 | 'env:publicPath': publicPath, |
| 252 | }, |
| 253 | }) |
| 254 | ); |
| 255 | } |
| 256 | |
| 257 | if (!BUILD_CONFIG.isElectron) { |
| 258 | plugins.push(CorsPlugin); |
| 259 | } |
| 260 | |
| 261 | if (config.emitAssetsManifest) { |
no test coverage detected