Metalsmith plugin that packs, minifies, and uglifies JavaScript files from HTML pages. Version 0.2.0 (last released in 2020, no recent updates). It scans generated HTML for script tags (external, inline, internal), bundles them into a single minified file, and writes the result to the filesystem. Supports excluding specific scripts via data-packer attribute, inline output mode, custom output path, and uglify options. Designed for Metalsmith static site generator workflows. Alternative to metalsmith-in-place or manual webpack/gulp integration for JS bundling.
npm install metalsmith-js-packerNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Basic Metalsmith build with js-packer plugin minifying JavaScript into a single file.
Use a Metalsmith cleanup plugin or manually remove old build files before each build.
Consider using metalsmith-in-place with modern minifier (Terser) or migrate to build tools like Vite.
Use the data-packer='exclude' attribute on script tags you want to keep separate.
Ensure inline scripts are wrapped in IIFE or use block-scoped declarations.
Ensure your HTML is well-formed before passing to metalsmith.
Use `const jsPacker = require('metalsmith-js-packer');` instead of ES import.Run `npm install uglify-js` or `npm install --save uglify-js`.
Wrap code in IIFE or use modules. Alternatively, exclude scripts that must maintain order using data-packer='exclude'.