Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// 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.*)$/,
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
}));