How to use the @angular/service-worker/build/webpack.AngularServiceWorkerPlugin function in @angular/service-worker

To help you get started, we’ve selected a few @angular/service-worker examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fossasia / susper.com / node_modules / @angular / cli / models / webpack-configs / production.js View on Github external
// So for now we keep it here, but if AngularServiceWorkerPlugin changes we remove it.
            extraPlugins.push(new glob_copy_webpack_plugin_1.GlobCopyWebpackPlugin({
                patterns: [
                    'ngsw-manifest.json',
                    { glob: 'ngsw-manifest.json',
                        input: path.resolve(projectRoot, appConfig.root), output: '' }
                ],
                globOptions: {
                    cwd: projectRoot,
                    optional: true,
                },
            }));
            // Load the Webpack plugin for manifest generation and install it.
            const AngularServiceWorkerPlugin = require('@angular/service-worker/build/webpack')
                .AngularServiceWorkerPlugin;
            extraPlugins.push(new AngularServiceWorkerPlugin({
                baseHref: buildOptions.baseHref || '/',
            }));
            // Copy the worker script into assets.
            const workerContents = fs.readFileSync(workerPath).toString();
            extraPlugins.push(new static_asset_1.StaticAssetPlugin('worker-basic.min.js', workerContents));
            // Add a script to index.html that registers the service worker.
            // TODO(alxhub): inline this script somehow.
            entryPoints['sw-register'] = [registerPath];
        }
    }
    extraPlugins.push(new bundle_budget_1.BundleBudgetPlugin({
        budgets: appConfig.budgets
    }));
    if (buildOptions.extractLicenses) {
        extraPlugins.push(new license_webpack_plugin_1.LicenseWebpackPlugin({
            pattern: /^(MIT|ISC|BSD.*)$/,
github angular / angular-cli / packages / angular_devkit / build_webpack / src / angular-cli-files / models / webpack-configs / production.ts View on Github external
extraPlugins.push(new GlobCopyWebpackPlugin({
        patterns: [
          'ngsw-manifest.json',
          { glob: 'ngsw-manifest.json',
            input: path.resolve(projectRoot, appConfig.root), output: '' }
        ],
        globOptions: {
          cwd: projectRoot,
          optional: true,
        },
      }));

      // Load the Webpack plugin for manifest generation and install it.
      const AngularServiceWorkerPlugin = require('@angular/service-worker/build/webpack')
        .AngularServiceWorkerPlugin;
      extraPlugins.push(new AngularServiceWorkerPlugin({
        baseHref: buildOptions.baseHref || '/',
      }));

      // Copy the worker script into assets.
      const workerContents = fs.readFileSync(workerPath).toString();
      extraPlugins.push(new StaticAssetPlugin('worker-basic.min.js', workerContents));

      // Add a script to index.html that registers the service worker.
      // TODO(alxhub): inline this script somehow.
      entryPoints['sw-register'] = [registerPath];
    }
  }

  extraPlugins.push(new BundleBudgetPlugin({
    budgets: appConfig.budgets
  }));