AssetGraph-builder is a robust, opinionated build system primarily designed for single-page web applications, leveraging the powerful AssetGraph library. It distinguishes itself by requiring no explicit build manifest; instead, it intelligently discovers all project assets (HTML, CSS, JavaScript, images, fonts, etc.) by traversing the dependency graph from specified HTML entry points. The current stable version is 9.3.0. While no fixed release cadence is stated, the project demonstrates active maintenance with recent updates, with the latest release in December 2023. Key features include bundling, minification (JavaScript with Terser, CSS with cssnano, HTML with html-minifier), advanced image optimization (supporting various tools like Sharp, pngquant, jpegtran), cache busting via MD5-hashed filenames, CDN rewriting, and automatic Content-Security-Policy updates. It excels in optimizing web assets for production, reducing HTTP requests, and improving load times, making it suitable for complex static site and web application deployments without extensive configuration.
npm install assetgraph-builderVerified import paths — ran on the pinned version, not inferred.
Installs the global CLI tool and builds a production-ready website from an HTML entry point, optimizing assets to a specified output directory.
Consult the 'Installation' section of the README for instructions on installing required external system libraries for full functionality, typically via a package manager like `apt` on Linux or `brew` on macOS.
Ensure your primary HTML entry files accurately reference all critical assets. For complex scenarios, understand AssetGraph's underlying traversal logic and its extensibility to fine-tune asset discovery and processing.
Configure your deployment and CDN solutions to handle dynamically generated, hashed filenames. This typically involves serving assets from a dedicated folder with far-future expiry headers and ensuring that your HTML references the new hashed names correctly.
Thoroughly review the generated CSP after a build. Test your application in various environments to ensure the updated CSP is still secure and functional. If server-side CSPs are in use, ensure they are compatible with the client-side meta tag modifications or disable automatic CSP updates if finer control is needed.
Install the missing command-line tools on your operating system. For example, on Ubuntu/Debian: `sudo apt-get install pngquant optipng jpegtran`. For macOS using Homebrew: `brew install pngquant optipng libjpeg`.
Verify the absolute or relative path to your primary HTML entry file. Ensure the command is executed from a directory where the relative path is correct, or provide the full absolute path.
Ensure `assetgraph` is installed alongside `assetgraph-builder`. If using npm, `npm install assetgraph` in your project directory. If `assetgraph-builder` is installed globally, you might need to ensure global peer dependencies are met or install `assetgraph` locally in projects where you run the builder.