1 | module.exports = (argv, config) => {
|
2 | if (argv.pwa) {
|
3 | const path = require('path');
|
4 | const WebpackPwaManifest = require('webpack-pwa-manifest');
|
5 | const pwaManifestConfigPath = path.resolve(process.cwd(), 'pwa-manifest.config.js');
|
6 | const { GenerateSW, InjectManifest } = require('workbox-webpack-plugin');
|
7 | const workboxConfigPath = path.resolve(process.cwd(), 'workbox-config.js');
|
8 |
|
9 | config.plugins.push(new WebpackPwaManifest(require(pwaManifestConfigPath)));
|
10 |
|
11 | switch (argv.pwa) {
|
12 | case 'injectManifest':
|
13 | config.plugins.push(new InjectManifest(require(workboxConfigPath)));
|
14 | break;
|
15 | case 'generateSW':
|
16 | default:
|
17 | config.plugins.push(new GenerateSW(require(workboxConfigPath)));
|
18 | }
|
19 | }
|
20 | };
|