The `offline-bundler-plugin` is a JavaScript/TypeScript utility designed to prepare web applications for offline access. It automates the process of compressing static assets (including JavaScript, CSS, images, and HTML) into a single zip archive and simultaneously generates a resource mapping JSON file. This manifest maps remote URLs of assets to their corresponding local paths within the generated bundle, facilitating efficient offline caching and retrieval. Currently at version 1.0.3, the plugin boasts compatibility with both Webpack and Vite (including UniApp environments), offering broad utility across modern frontend build setups. Its key differentiator lies in its dual-bundler support and its specialized focus on creating structured resource manifests, which goes beyond simple asset compression to enable robust offline-first strategies.
npm install offline-bundler-pluginVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to configure `offline-bundler-plugin` for both Webpack and Vite projects, highlighting the distinct import and instantiation patterns for each bundler. It shows basic configuration options for bundling static assets into a zip with a resource mapping JSON.
For Vite: `plugins: [OfflinePackagePlugin(...)]`. For Webpack: `plugins: [new OfflinePackagePlugin(...)]`.
Ensure `require('offline-bundler-plugin')` (CommonJS) is used for Webpack configurations, and `import OfflinePackagePlugin from 'offline-bundler-plugin/vite'` (ESM) for Vite configurations.Adhere to the standard module system for each bundler: `const MyPlugin = require('my-plugin')` for Webpack and `import MyPlugin from 'my-plugin'` for Vite. If using TypeScript with Webpack, ensure your `tsconfig.json` targets `CommonJS` or uses dynamic imports.Remove the `new` keyword when using the plugin in Vite. Correct usage: `OfflinePackagePlugin({...options})`.For Webpack, use `require('offline-bundler-plugin')`. For Vite, ensure `import OfflinePackagePlugin from 'offline-bundler-plugin/vite'` and that `offline-bundler-plugin` is installed as a dev dependency.For Vite, use `import OfflinePackagePlugin from 'offline-bundler-plugin/vite'`. For Webpack, ensure `require('offline-bundler-plugin')` and that `offline-bundler-plugin` is installed as a dev dependency.No dependency data recorded yet.