CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-workbox-webpack-plugin

A plugin for your Webpack build process, helping you generate a manifest of local files that workbox-sw should precache.

Overall
score

80%

Overview
Eval results
Files

task.mdevals/scenario-10/

Sourcemap-Safe Precache Build

Build a bundling routine that injects a precache manifest into a service worker while keeping the generated sourcemap accurate after the placeholder replacement.

Capabilities

Manifest injection with map output

  • Given a service worker source file containing the placeholder __INJECT_PRECACHE__ and an external sourcemap comment, running the build writes sw.js with that placeholder replaced by the provided manifest entries and emits sw.js.map that references the injected code instead of the placeholder. @test

Mapping integrity after insertion

  • The generated sourcemap keeps the original line-and-column mappings for code before and after the placeholder, so statements following the injected manifest still resolve to their original source locations. @test

Map regeneration when manifest changes

  • Changing the manifest entries between builds updates both sw.js and sw.js.map so the map length and mappings match the new manifest string rather than a stale offset. @test

Implementation

@generates

API

/**
 * Builds a service worker bundle with an injected precache manifest and sourcemap support.
 *
 * @param {Object} options
 * @param {string} options.swSrc - Path to the service worker source that includes the manifest placeholder.
 * @param {string} options.swDest - Output path for the built service worker JavaScript file.
 * @param {Array<{url: string, revision: string}>} options.manifestEntries - Precache entries to inject.
 * @param {string} [options.publicPath] - Optional public URL prefix to apply to manifest URLs.
 * @param {boolean} [options.enableSourceMap=true] - Whether to emit and update a sourcemap alongside the output.
 * @returns {Promise<{swPath: string, mapPath?: string}>} Resolves with written file paths once bundling completes.
 */
async function buildServiceWorker(options);

Dependencies { .dependencies }

workbox-webpack-plugin { .dependency }

Provides bundle-time precache manifest injection and sourcemap-aware replacement. @satisfied-by

webpack { .dependency }

Build toolchain used to compile the service worker bundle and emit assets. @satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-workbox-webpack-plugin

tile.json