Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
compilation.assets[manifestFilename] = manifestAsset;
this.config.importScripts.push(
(compilation.options.output.publicPath || '') + manifestFilename);
// workboxSWImports might be null if importWorkboxFrom is 'disabled'.
if (workboxSWImports) {
// workboxSWImport is an array, so use concat() rather than push().
this.config.importScripts = this.config.importScripts.concat(
workboxSWImports);
}
const sanitizedConfig = sanitizeConfig.forGenerateSWString(this.config);
// If globPatterns isn't explicitly set, then default to [], instead of
// the workbox-build.generateSWString() default.
sanitizedConfig.globPatterns = sanitizedConfig.globPatterns || [];
const serviceWorker = await generateSWString(sanitizedConfig);
compilation.assets[this.config.swDest] =
convertStringToAsset(serviceWorker);
}
const manifestFilename = `precache-manifest.${manifestHash}.js`;
compilation.assets[manifestFilename] = manifestAsset;
this.config.importScripts.push(manifestFilename);
// workboxSWImports might be null if importWorkboxFrom is 'disabled'.
if (workboxSWImports) {
// workboxSWImport is an array, so use concat() rather than push().
this.config.importScripts = this.config.importScripts.concat(
workboxSWImports);
}
const sanitizedConfig = sanitizeConfig.forGenerateSWString(this.config);
// If globPatterns isn't explicitly set, then default to [], instead of
// the workbox-build.generateSWString() default.
sanitizedConfig.globPatterns = sanitizedConfig.globPatterns || [];
const serviceWorker = await generateSWString(sanitizedConfig);
compilation.assets[this.config.swDest] =
convertStringToAsset(serviceWorker);
}
async generateSW(swDest, swConfig) {
const { swString } = await generateSWString(swConfig);
fs.writeFileSync(swDest, swString);
}