Install command
Provided
Analyzes webpack bundle size when webpack config or entry files are modified.
Open the source and read safety notes before installing.
Source-backed facts for citing this resource, derived directly from the registry — also available as plain text for AI assistants.
Decision playbook
Signals are present but mixed. Use the checklist below to confirm the source and operational safety for your environment.
0
78
—
No baseline selected
No major trust-signal divergence detected in the current selection.
Confirm ownership and provenance before trusting install instructions.
Source link availableRequired
Open the canonical repository and verify ownership.
Source provenance statusRequired
Marked as source-backed.
Metadata reviewed
Registry metadata indicates a reviewed listing.
Validate risk disclosures before installation or API wiring.
Safety notes presentRequired
Review the listed safety guidance before running commands.
Privacy notes presentRequired
Review data handling notes before connecting accounts or secrets.
Trust level risk gateRequired
Trust level does not block evaluation.
Check package metadata and artifact integrity signals.
Install payload available
Install or copy payload is available for review.
Package verification flag
No package verification flag provided.
Checksum metadata
No checksum provided for downloaded artifact.
Use compare context to validate trade-offs before adoption.
Compare tray has multiple entries
Add at least one more entry to compare trust differences.
Baseline comparison available
No baseline peer selected yet.
Diverging trust signals identified
No major trust-signal divergence found.
Setup at a glance
Copy-ready — paste the snippet to get started.
Install command
Provided
Config snippet
Provided
Copy snippet
Provided
Prerequisites
None
Platforms
1 listed
Difficulty
0/100
Adoption plan
Current risk score 16/100. Use staged verification before broader rollout.
Validate source and review signals before any execution.
Confirm source provenanceRequired
Source URL/provenance metadata is present.
Confirm metadata review state
Listing has review metadata.
Verify install payload
Install/config payload exists and can be inspected.
Confirm safety, privacy, and package integrity signals.
Review safety notesRequired
Safety notes are present.
Review privacy notesRequired
Privacy notes are present.
Verify package integrity metadata
No package verification/checksum metadata.
Adopt in controlled steps based on the selected plan.
Run in isolated sandbox firstRequired
Use a constrained sandbox and observe behavior across multiple tasks.
Roll out graduallyRequired
Roll out to a small cohort before wider usage.
Set monitoring and fallback
Define rollback path and monitor errors after adoption.
Evidence readiness
Required evidence gates are covered (5/6 signals complete).
Source repository/provenance is listed.
Required in this preset
Review metadata is present.
Required in this preset
Safety notes are present.
Required in this preset
Privacy notes are present.
Optional in this preset
Package integrity metadata is missing.
Optional in this preset
Install payload is available.
Required in this preset
Required evidence gates are covered for this preset.
Decision timeline
5/6 steps complete with no blocking gaps for this preset.
triage
Source/provenance metadata is available.
triage
Review metadata is available.
verify
Safety notes are available.
verify
Privacy notes are available.
verify
Package integrity metadata is missing.
rollout
Install payload is available.
No required blockers for this timeline preset.
Safety & privacy surface
1 safety and 1 privacy notes across 2 risk areas. Review closely: credentials & tokens, permissions & scopes.
#!/bin/bash
# Read the tool input from stdin
INPUT=$(cat)
TOOL_NAME=$(echo "$INPUT" | jq -r '.tool_name')
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // .tool_input.path // ""')
if [ -z "$FILE_PATH" ]; then
exit 0
fi
echo "📊 Webpack Bundle Analyzer - Analyzing bundle performance..."
echo "📄 File: $FILE_PATH"
# Check if this is a relevant file for bundle analysis
RELEVANT_FILE=false
if [[ "$FILE_PATH" == *webpack.config.js ]] || \
[[ "$FILE_PATH" == *webpack.config.ts ]] || \
[[ "$FILE_PATH" == *vite.config.js ]] || \
[[ "$FILE_PATH" == *vite.config.ts ]] || \
[[ "$FILE_PATH" == *rollup.config.js ]] || \
[[ "$FILE_PATH" == *src/index.js ]] || \
[[ "$FILE_PATH" == *src/index.ts ]] || \
[[ "$FILE_PATH" == *src/main.js ]] || \
[[ "$FILE_PATH" == *src/main.ts ]] || \
[[ "$FILE_PATH" == *package.json ]]; then
RELEVANT_FILE=true
fi
if [ "$RELEVANT_FILE" = false ]; then
echo "ℹ️ File does not require bundle analysis: $FILE_PATH"
exit 0
fi
echo "🔍 Detecting build system and configuration..."
# Detect build system
BUILD_SYSTEM="unknown"
if [ -f "webpack.config.js" ] || [ -f "webpack.config.ts" ]; then
BUILD_SYSTEM="webpack"
echo "📦 Webpack configuration detected"
elif [ -f "vite.config.js" ] || [ -f "vite.config.ts" ]; then
BUILD_SYSTEM="vite"
echo "⚡ Vite configuration detected"
elif [ -f "rollup.config.js" ] || [ -f "rollup.config.ts" ]; then
BUILD_SYSTEM="rollup"
echo "🎯 Rollup configuration detected"
elif [ -f "package.json" ] && grep -q '"react-scripts"' package.json 2>/dev/null; then
BUILD_SYSTEM="cra"
echo "⚛️ Create React App detected"
elif [ -f "next.config.js" ] || [ -f "next.config.ts" ]; then
BUILD_SYSTEM="next"
echo "🔺 Next.js configuration detected"
else
echo "❓ No recognized build system found"
fi
# Check for bundle analyzer availability
ANALYZER_AVAILABLE=false
if command -v npx >/dev/null 2>&1; then
if npx webpack-bundle-analyzer --version >/dev/null 2>&1; then
ANALYZER_AVAILABLE=true
echo "✅ webpack-bundle-analyzer available"
else
echo "⚠️ webpack-bundle-analyzer not available - install with: npm install --save-dev webpack-bundle-analyzer"
fi
else
echo "⚠️ npx not available - please install Node.js"
fi
# Perform bundle analysis based on build system
case "$BUILD_SYSTEM" in
"webpack")
echo "📊 Analyzing Webpack bundle..."
# Check if dist directory exists
if [ ! -d "dist" ] && [ ! -d "build" ]; then
echo "🏗️ Building project to generate bundle..."
if npm run build 2>/dev/null; then
echo "✅ Build completed successfully"
else
echo "❌ Build failed - cannot analyze bundle"
exit 1
fi
fi
# Find stats file or generate one
STATS_FILE=""
if [ -f "dist/stats.json" ]; then
STATS_FILE="dist/stats.json"
elif [ -f "build/stats.json" ]; then
STATS_FILE="build/stats.json"
else
echo "📈 Generating webpack stats..."
if npx webpack --profile --json > webpack-stats.json 2>/dev/null; then
STATS_FILE="webpack-stats.json"
echo "✅ Stats file generated: $STATS_FILE"
else
echo "❌ Failed to generate webpack stats"
exit 1
fi
fi
# Run bundle analyzer
if [ "$ANALYZER_AVAILABLE" = true ] && [ -n "$STATS_FILE" ]; then
echo "🔍 Running bundle analysis..."
if npx webpack-bundle-analyzer "$STATS_FILE" --mode static --report bundle-report.html --no-open 2>/dev/null; then
echo "✅ Bundle analysis completed"
echo "📊 Report saved to: bundle-report.html"
echo "🌐 View report: file://$(pwd)/bundle-report.html"
else
echo "⚠️ Bundle analysis failed"
fi
fi
;;
"vite")
echo "⚡ Analyzing Vite bundle..."
# Check if Vite has bundle analysis plugin
if grep -q 'vite-bundle-analyzer\|rollup-plugin-analyzer' package.json 2>/dev/null; then
echo "📊 Running Vite bundle analysis..."
if npm run build -- --analyze 2>/dev/null; then
echo "✅ Vite bundle analysis completed"
else
echo "⚠️ Vite bundle analysis failed"
fi
else
echo "💡 Install vite-bundle-analyzer for detailed analysis:"
echo " npm install --save-dev vite-bundle-analyzer"
# Basic build size analysis
echo "📏 Running basic build analysis..."
if npm run build 2>/dev/null; then
if [ -d "dist" ]; then
echo "📊 Build output analysis:"
find dist -name "*.js" -exec du -h {} \; | sort -hr | head -10
fi
fi
fi
;;
"next")
echo "🔺 Analyzing Next.js bundle..."
if grep -q '@next/bundle-analyzer' package.json 2>/dev/null; then
echo "📊 Running Next.js bundle analysis..."
if ANALYZE=true npm run build 2>/dev/null; then
echo "✅ Next.js bundle analysis completed"
else
echo "⚠️ Next.js bundle analysis failed"
fi
else
echo "💡 Install @next/bundle-analyzer for detailed analysis:"
echo " npm install --save-dev @next/bundle-analyzer"
fi
;;
"cra")
echo "⚛️ Analyzing Create React App bundle..."
if npm list --depth=0 | grep -q 'source-map-explorer' 2>/dev/null; then
echo "📊 Running source-map-explorer..."
if npm run build && npx source-map-explorer 'build/static/js/*.js' 2>/dev/null; then
echo "✅ CRA bundle analysis completed"
else
echo "⚠️ CRA bundle analysis failed"
fi
else
echo "💡 Install source-map-explorer for detailed analysis:"
echo " npm install --save-dev source-map-explorer"
fi
;;
*)
echo "❓ Unknown build system - attempting generic analysis"
# Try to analyze any existing build output
for dir in dist build public; do
if [ -d "$dir" ]; then
echo "📊 Analyzing $dir directory:"
find "$dir" -name "*.js" -o -name "*.css" | head -10 | while read -r file; do
size=$(du -h "$file" 2>/dev/null | cut -f1)
echo " • $file: $size"
done
fi
done
;;
esac
# General optimization suggestions
echo ""
echo "💡 Bundle Optimization Tips:"
echo " • Enable tree-shaking to remove unused code"
echo " • Use dynamic imports for code splitting"
echo " • Optimize images and static assets"
echo " • Use compression (gzip/brotli) for production"
echo " • Analyze and remove large unnecessary dependencies"
echo " • Use webpack-bundle-analyzer for detailed insights"
echo " • Consider lazy loading for non-critical components"
echo " • Review and optimize polyfills"
echo ""
echo "📊 Bundle Analysis Tools:"
echo " • Webpack: webpack-bundle-analyzer"
echo " • Vite: vite-bundle-analyzer"
echo " • Next.js: @next/bundle-analyzer"
echo " • CRA: source-map-explorer"
echo " • General: bundlephobia.com for dependency analysis"
echo ""
echo "🎯 Bundle analysis complete!"
exit 0{
"hooks": {
"postToolUse": {
"script": "./.claude/hooks/webpack-bundle-analyzer.sh",
"matchers": [
"write",
"edit"
]
}
}
}.claude/settings.local.json~/.claude/settings.json.claude/settings.json{
"hooks": {
"postToolUse": {
"script": "./.claude/hooks/webpack-bundle-analyzer.sh",
"matchers": ["write", "edit"]
}
}
}
#!/bin/bash
# Read the tool input from stdin
INPUT=$(cat)
TOOL_NAME=$(echo "$INPUT" | jq -r '.tool_name')
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // .tool_input.path // ""')
if [ -z "$FILE_PATH" ]; then
exit 0
fi
echo "📊 Webpack Bundle Analyzer - Analyzing bundle performance..."
echo "📄 File: $FILE_PATH"
# Check if this is a relevant file for bundle analysis
RELEVANT_FILE=false
if [[ "$FILE_PATH" == *webpack.config.js ]] || \
[[ "$FILE_PATH" == *webpack.config.ts ]] || \
[[ "$FILE_PATH" == *vite.config.js ]] || \
[[ "$FILE_PATH" == *vite.config.ts ]] || \
[[ "$FILE_PATH" == *rollup.config.js ]] || \
[[ "$FILE_PATH" == *src/index.js ]] || \
[[ "$FILE_PATH" == *src/index.ts ]] || \
[[ "$FILE_PATH" == *src/main.js ]] || \
[[ "$FILE_PATH" == *src/main.ts ]] || \
[[ "$FILE_PATH" == *package.json ]]; then
RELEVANT_FILE=true
fi
if [ "$RELEVANT_FILE" = false ]; then
echo "ℹ️ File does not require bundle analysis: $FILE_PATH"
exit 0
fi
echo "🔍 Detecting build system and configuration..."
# Detect build system
BUILD_SYSTEM="unknown"
if [ -f "webpack.config.js" ] || [ -f "webpack.config.ts" ]; then
BUILD_SYSTEM="webpack"
echo "📦 Webpack configuration detected"
elif [ -f "vite.config.js" ] || [ -f "vite.config.ts" ]; then
BUILD_SYSTEM="vite"
echo "⚡ Vite configuration detected"
elif [ -f "rollup.config.js" ] || [ -f "rollup.config.ts" ]; then
BUILD_SYSTEM="rollup"
echo "🎯 Rollup configuration detected"
elif [ -f "package.json" ] && grep -q '"react-scripts"' package.json 2>/dev/null; then
BUILD_SYSTEM="cra"
echo "⚛️ Create React App detected"
elif [ -f "next.config.js" ] || [ -f "next.config.ts" ]; then
BUILD_SYSTEM="next"
echo "🔺 Next.js configuration detected"
else
echo "❓ No recognized build system found"
fi
# Check for bundle analyzer availability
ANALYZER_AVAILABLE=false
if command -v npx >/dev/null 2>&1; then
if npx webpack-bundle-analyzer --version >/dev/null 2>&1; then
ANALYZER_AVAILABLE=true
echo "✅ webpack-bundle-analyzer available"
else
echo "⚠️ webpack-bundle-analyzer not available - install with: npm install --save-dev webpack-bundle-analyzer"
fi
else
echo "⚠️ npx not available - please install Node.js"
fi
# Perform bundle analysis based on build system
case "$BUILD_SYSTEM" in
"webpack")
echo "📊 Analyzing Webpack bundle..."
# Check if dist directory exists
if [ ! -d "dist" ] && [ ! -d "build" ]; then
echo "🏗️ Building project to generate bundle..."
if npm run build 2>/dev/null; then
echo "✅ Build completed successfully"
else
echo "❌ Build failed - cannot analyze bundle"
exit 1
fi
fi
# Find stats file or generate one
STATS_FILE=""
if [ -f "dist/stats.json" ]; then
STATS_FILE="dist/stats.json"
elif [ -f "build/stats.json" ]; then
STATS_FILE="build/stats.json"
else
echo "📈 Generating webpack stats..."
if npx webpack --profile --json > webpack-stats.json 2>/dev/null; then
STATS_FILE="webpack-stats.json"
echo "✅ Stats file generated: $STATS_FILE"
else
echo "❌ Failed to generate webpack stats"
exit 1
fi
fi
# Run bundle analyzer
if [ "$ANALYZER_AVAILABLE" = true ] && [ -n "$STATS_FILE" ]; then
echo "🔍 Running bundle analysis..."
if npx webpack-bundle-analyzer "$STATS_FILE" --mode static --report bundle-report.html --no-open 2>/dev/null; then
echo "✅ Bundle analysis completed"
echo "📊 Report saved to: bundle-report.html"
echo "🌐 View report: file://$(pwd)/bundle-report.html"
else
echo "⚠️ Bundle analysis failed"
fi
fi
;;
"vite")
echo "⚡ Analyzing Vite bundle..."
# Check if Vite has bundle analysis plugin
if grep -q 'vite-bundle-analyzer\|rollup-plugin-analyzer' package.json 2>/dev/null; then
echo "📊 Running Vite bundle analysis..."
if npm run build -- --analyze 2>/dev/null; then
echo "✅ Vite bundle analysis completed"
else
echo "⚠️ Vite bundle analysis failed"
fi
else
echo "💡 Install vite-bundle-analyzer for detailed analysis:"
echo " npm install --save-dev vite-bundle-analyzer"
# Basic build size analysis
echo "📏 Running basic build analysis..."
if npm run build 2>/dev/null; then
if [ -d "dist" ]; then
echo "📊 Build output analysis:"
find dist -name "*.js" -exec du -h {} \; | sort -hr | head -10
fi
fi
fi
;;
"next")
echo "🔺 Analyzing Next.js bundle..."
if grep -q '@next/bundle-analyzer' package.json 2>/dev/null; then
echo "📊 Running Next.js bundle analysis..."
if ANALYZE=true npm run build 2>/dev/null; then
echo "✅ Next.js bundle analysis completed"
else
echo "⚠️ Next.js bundle analysis failed"
fi
else
echo "💡 Install @next/bundle-analyzer for detailed analysis:"
echo " npm install --save-dev @next/bundle-analyzer"
fi
;;
"cra")
echo "⚛️ Analyzing Create React App bundle..."
if npm list --depth=0 | grep -q 'source-map-explorer' 2>/dev/null; then
echo "📊 Running source-map-explorer..."
if npm run build && npx source-map-explorer 'build/static/js/*.js' 2>/dev/null; then
echo "✅ CRA bundle analysis completed"
else
echo "⚠️ CRA bundle analysis failed"
fi
else
echo "💡 Install source-map-explorer for detailed analysis:"
echo " npm install --save-dev source-map-explorer"
fi
;;
*)
echo "❓ Unknown build system - attempting generic analysis"
# Try to analyze any existing build output
for dir in dist build public; do
if [ -d "$dir" ]; then
echo "📊 Analyzing $dir directory:"
find "$dir" -name "*.js" -o -name "*.css" | head -10 | while read -r file; do
size=$(du -h "$file" 2>/dev/null | cut -f1)
echo " • $file: $size"
done
fi
done
;;
esac
# General optimization suggestions
echo ""
echo "💡 Bundle Optimization Tips:"
echo " • Enable tree-shaking to remove unused code"
echo " • Use dynamic imports for code splitting"
echo " • Optimize images and static assets"
echo " • Use compression (gzip/brotli) for production"
echo " • Analyze and remove large unnecessary dependencies"
echo " • Use webpack-bundle-analyzer for detailed insights"
echo " • Consider lazy loading for non-critical components"
echo " • Review and optimize polyfills"
echo ""
echo "📊 Bundle Analysis Tools:"
echo " • Webpack: webpack-bundle-analyzer"
echo " • Vite: vite-bundle-analyzer"
echo " • Next.js: @next/bundle-analyzer"
echo " • CRA: source-map-explorer"
echo " • General: bundlephobia.com for dependency analysis"
echo ""
echo "🎯 Bundle analysis complete!"
exit 0
Complete hook script that automatically analyzes webpack bundle size when webpack config or entry files are modified
#!/bin/bash
INPUT=$(cat)
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // .tool_input.path // ""')
if [ -z "$FILE_PATH" ]; then
exit 0
fi
RELEVANT_FILE=false
if [[ "$FILE_PATH" == *webpack.config.js ]] || [[ "$FILE_PATH" == *webpack.config.ts ]] || [[ "$FILE_PATH" == *vite.config.js ]] || [[ "$FILE_PATH" == *vite.config.ts ]] || [[ "$FILE_PATH" == *package.json ]]; then
RELEVANT_FILE=true
fi
if [ "$RELEVANT_FILE" = false ]; then
exit 0
fi
echo "📊 Webpack Bundle Analyzer - Analyzing bundle performance..."
BUILD_SYSTEM="unknown"
if [ -f "webpack.config.js" ] || [ -f "webpack.config.ts" ]; then
BUILD_SYSTEM="webpack"
echo "📦 Webpack configuration detected"
if [ ! -d "dist" ] && [ ! -d "build" ]; then
echo "🏗️ Building project to generate bundle..."
if npm run build 2>/dev/null; then
echo "✅ Build completed successfully"
else
echo "❌ Build failed - cannot analyze bundle"
exit 1
fi
fi
STATS_FILE=""
if [ -f "dist/stats.json" ]; then
STATS_FILE="dist/stats.json"
elif [ -f "build/stats.json" ]; then
STATS_FILE="build/stats.json"
else
echo "📈 Generating webpack stats..."
if npx webpack --profile --json > webpack-stats.json 2>/dev/null; then
STATS_FILE="webpack-stats.json"
echo "✅ Stats file generated: $STATS_FILE"
fi
fi
if command -v npx >/dev/null 2>&1 && npx webpack-bundle-analyzer --version >/dev/null 2>&1; then
if [ -n "$STATS_FILE" ]; then
echo "🔍 Running bundle analysis..."
if npx webpack-bundle-analyzer "$STATS_FILE" --mode static --report bundle-report.html --no-open 2>/dev/null; then
echo "✅ Bundle analysis completed"
echo "📊 Report saved to: bundle-report.html"
fi
fi
fi
fi
echo "🎯 Bundle analysis complete!"
exit 0
Complete hook configuration for .claude/settings.json to enable automatic bundle analysis
{
"hooks": {
"postToolUse": {
"script": "./.claude/hooks/webpack-bundle-analyzer.sh",
"matchers": ["write", "edit"]
}
}
}
Enhanced hook script with support for Webpack, Vite, and Rollup bundle analysis
#!/bin/bash
INPUT=$(cat)
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // .tool_input.path // ""')
if [ -z "$FILE_PATH" ]; then
exit 0
fi
RELEVANT_FILE=false
if [[ "$FILE_PATH" == *webpack.config.js ]] || [[ "$FILE_PATH" == *vite.config.js ]] || [[ "$FILE_PATH" == *rollup.config.js ]] || [[ "$FILE_PATH" == *package.json ]]; then
RELEVANT_FILE=true
fi
if [ "$RELEVANT_FILE" = false ]; then
exit 0
fi
echo "📊 Webpack Bundle Analyzer - Analyzing bundle performance..."
BUILD_SYSTEM="unknown"
if [ -f "vite.config.js" ] || [ -f "vite.config.ts" ]; then
BUILD_SYSTEM="vite"
echo "⚡ Vite configuration detected"
if grep -q 'rollup-plugin-visualizer' package.json 2>/dev/null; then
echo "📊 Running Vite bundle analysis..."
if npm run build 2>/dev/null; then
echo "✅ Vite bundle analysis completed"
if [ -d "dist" ]; then
echo "📊 Build output analysis:"
find dist -name "*.js" -exec du -h {} \; | sort -hr | head -10
fi
fi
else
echo "💡 Install rollup-plugin-visualizer for detailed analysis:"
echo " npm install --save-dev rollup-plugin-visualizer"
fi
elif [ -f "rollup.config.js" ] || [ -f "rollup.config.ts" ]; then
BUILD_SYSTEM="rollup"
echo "🎯 Rollup configuration detected"
if grep -q 'rollup-plugin-visualizer' package.json 2>/dev/null; then
echo "📊 Running Rollup bundle analysis..."
if npm run build 2>/dev/null; then
echo "✅ Rollup bundle analysis completed"
fi
fi
fi
echo "🎯 Bundle analysis complete!"
exit 0
Enhanced hook script with build cache to skip rebuilds for unchanged configurations
#!/bin/bash
INPUT=$(cat)
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // .tool_input.path // ""')
if [ -z "$FILE_PATH" ]; then
exit 0
fi
if [[ "$FILE_PATH" == *webpack.config.js ]] || [[ "$FILE_PATH" == *package.json ]]; then
echo "📊 Webpack Bundle Analyzer - Analyzing bundle performance..."
if [ -f "webpack-stats.json" ]; then
CONFIG_HASH=$(md5sum webpack.config.js 2>/dev/null | cut -d' ' -f1 || echo "")
if [ -n "$CONFIG_HASH" ]; then
CACHE_FILE=".bundle-analyzed-$CONFIG_HASH"
if [ -f "$CACHE_FILE" ]; then
echo "✅ Bundle already analyzed for this configuration"
exit 0
fi
touch "$CACHE_FILE"
fi
fi
if [ ! -d "dist" ] && [ ! -d "build" ]; then
echo "🏗️ Building project to generate bundle..."
if npm run build 2>/dev/null; then
echo "✅ Build completed successfully"
else
echo "❌ Build failed - cannot analyze bundle"
exit 1
fi
fi
STATS_FILE=""
if [ -f "dist/stats.json" ]; then
STATS_FILE="dist/stats.json"
elif [ -f "build/stats.json" ]; then
STATS_FILE="build/stats.json"
else
echo "📈 Generating webpack stats..."
if npx webpack --profile --json > webpack-stats.json 2>/dev/null; then
STATS_FILE="webpack-stats.json"
fi
fi
if command -v npx >/dev/null 2>&1 && npx webpack-bundle-analyzer --version >/dev/null 2>&1; then
if [ -n "$STATS_FILE" ]; then
echo "🔍 Running bundle analysis..."
if npx webpack-bundle-analyzer "$STATS_FILE" --mode static --report bundle-report.html --no-open 2>/dev/null; then
echo "✅ Bundle analysis completed"
echo "📊 Report saved to: bundle-report.html"
fi
fi
fi
fi
echo "🎯 Bundle analysis complete!"
exit 0
Example webpack bundle analyzer configuration for customizing bundle analysis behavior
{
"webpack_bundle_analyzer": {
"enabled": true,
"build_systems": ["webpack", "vite", "rollup", "next", "cra"],
"auto_build": true,
"cache_analysis": true,
"tools": {
"webpack": {
"analyzer": "webpack-bundle-analyzer",
"stats_command": "webpack --profile --json",
"stats_file": "webpack-stats.json"
},
"vite": {
"analyzer": "rollup-plugin-visualizer",
"build_command": "npm run build"
},
"rollup": {
"analyzer": "rollup-plugin-visualizer",
"build_command": "npm run build"
},
"next": {
"analyzer": "@next/bundle-analyzer",
"build_command": "ANALYZE=true npm run build"
},
"cra": {
"analyzer": "source-map-explorer",
"build_command": "npm run build"
}
},
"file_patterns": [
"*webpack.config.*",
"*vite.config.*",
"*rollup.config.*",
"package.json",
"src/index.*",
"src/main.*"
],
"exclude_patterns": ["**/node_modules/**", "**/dist/**", "**/build/**"]
}
}
Add build skip flag or cache check: if [ -f .bundle-analyzed-$(md5sum webpack.config.js | cut -d' ' -f1) ]; then exit 0; fi to track analyzed configs and skip rebuilds for unchanged hashes. Verify cache file creation. Check config hash calculation.
Hook uses --no-open flag: npx webpack-bundle-analyzer "$STATS_FILE" --mode static --report bundle-report.html --no-open. Verify flag is present in script to prevent browser launch. Check webpack-bundle-analyzer version.
Check webpack config validity first: npx webpack --config webpack.config.js --json > /dev/null 2>&1 to test. If fails, examine error with npx webpack --profile --json 2>&1 | tee webpack-errors.log. Verify webpack configuration. Check webpack version compatibility.
Install plugin: npm i -D rollup-plugin-visualizer, add to vite.config: import { visualizer } from 'rollup-plugin-visualizer'; plugins: [visualizer()], rebuild. Verify vite.config.js. Check Vite version compatibility.
Detection scans root only. For workspace builds, modify check: if [[ "$FILE_PATH" == packages/app/* ]]; then cd packages/app; BUILD_SYSTEM=...; fi. Verify monorepo structure. Check workspace configuration.
Verify webpack-bundle-analyzer installation: 'npm list webpack-bundle-analyzer' or 'npx webpack-bundle-analyzer --version'. Install: 'npm install --save-dev webpack-bundle-analyzer'. Check PATH. Verify Node.js version compatibility.
Verify stats file exists and is valid JSON. Check webpack-bundle-analyzer version supports --report flag. Ensure write permissions for report directory. Verify --mode static flag. Test webpack-bundle-analyzer command manually.
Set ANALYZE environment variable: 'ANALYZE=true npm run build'. Or configure @next/bundle-analyzer in next.config.js. Verify Next.js configuration. Check @next/bundle-analyzer installation.
Webpack Bundle Analyzer - Hooks side by side with 3 alternatives on trust, install, platform support, and disclosed safety notes — all from reviewed registry metadata.
Next steps differ across entries — use the actions in the table below to copy install commands and source links per resource.
| Field | Analyzes webpack bundle size when webpack config or entry files are modified. Open dossier | Analyzes and reports final bundle sizes when the development session ends. Open dossier | Detects unused CSS selectors when stylesheets are modified to keep CSS lean using PurgeCSS, PostCSS, and content analysis. This hook runs on CSS/SCSS file write/edit operations and analyzes stylesheets to identify unused selectors, generate optimized output, and report before/after size metrics. Open dossier | A PostToolUse hook that reminds you to enable native query logging for PostgreSQL, Prisma, Sequelize, and TypeORM, and flags possible N+1 patterns when you edit SQL or data-access files. Open dossier |
|---|---|---|---|---|
| Next stepsDiffers | ||||
| Trust | ||||
| Review status | ReviewedMaintainer reviewed | ReviewedMaintainer reviewed | ReviewedMaintainer reviewed | ReviewedMaintainer reviewed |
| Package trust | Package not verified | Package not verified | Package not verified | Package not verified |
| Source provenance | Source-backed | Source-backed | Source-backed | Source-backed |
| Submitter | — | — | — | — |
| Install risk | Review first | Review first | Review first | Review first |
| Notes | Safety ✓ Privacy ✓ | Safety ✓ Privacy ✓ | Safety ✓ Privacy ✓ | Safety ✓ Privacy ✓ |
| Brand | — | — | — | — |
| Category | hooks | hooks | hooks | hooks |
| Source | source-backed | source-backed | source-backed | source-backed |
| Author | JSONbored | JSONbored | JSONbored | JSONbored |
| Added | 2025-09-19 | 2025-09-19 | 2025-09-19 | 2025-10-19 |
| Platforms | Claude Code | Claude Code | Claude Code | Claude Code |
| Source repo | — | — | — | — |
| Safety notes | ✓Runs automatically on its configured Claude Code hook event and executes shell logic that can read, modify, or delete files in your project (and may run builds, installs, or network calls); review the script and scope it to expected paths before enabling. | ✓Runs automatically on its configured Claude Code hook event and executes shell logic that can read, modify, or delete files in your project (and may run builds, installs, or network calls); review the script and scope it to expected paths before enabling. | ✓Runs automatically on its configured Claude Code hook event and executes shell logic that can read, modify, or delete files in your project (and may run builds, installs, or network calls); review the script and scope it to expected paths before enabling. | ✓Runs automatically after bash, write, or edit activity and inspects files that look like query, model, repository, DAO, or SQL files. Creates .claude/logs/query-performance.log and appends database command or file-analysis events. Uses grep-based heuristics for query warnings and should not be treated as proof of a performance defect. |
| Privacy notes | ✓Receives Claude Code hook input (session metadata, file paths, and tool output) and reads local project files; review what the script logs or forwards to external services and keep credentials out of its output. | ✓Receives Claude Code hook input (session metadata, file paths, and tool output) and reads local project files; review what the script logs or forwards to external services and keep credentials out of its output. | ✓Receives Claude Code hook input (session metadata, file paths, and tool output) and reads local project files; review what the script logs or forwards to external services and keep credentials out of its output. | ✓Reads query-related source files and may print file paths, query patterns, and database command strings to local hook output. Stores analyzed file paths and database command text in .claude/logs/query-performance.log. Database command text may include connection names, database names, or other operational details if typed directly into the command. |
| Prerequisites | — none listed | — none listed | — none listed | — none listed |
| Install | | | | — |
| Config | | | | |
| Citations | ||||
| Claim | Unclaimed | Unclaimed | Unclaimed | Unclaimed |
Source-backed guides for putting this to work.
Fix Claude Code high CPU/memory, hangs, and context bloat with documented commands.
Loading live community signals…
A short, calm digest of reviewed Claude resources. Unsubscribe any time.