Skip to content

Commit fb26e8a

Browse files
justin808claude
andcommitted
Improve bundle analysis instructions with complete workflow
Replace vague ANALYZE=true command with comprehensive bundle analysis guide: - Check if webpack-bundle-analyzer is installed and provide appropriate instructions - Add step-by-step setup: npm install --save-dev webpack-bundle-analyzer - Provide alternative analysis method: generate webpack-stats.json for online viewer - Include direct link to webpack.github.io/analyse for stats visualization - Make commands actionable with clear expected outcomes 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 21df888 commit fb26e8a

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

lib/react_on_rails/system_checker.rb

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,27 @@ def check_webpack_configuration
284284

285285
def suggest_webpack_inspection
286286
add_info("💡 To debug webpack builds: bin/shakapacker --progress --verbose")
287-
add_info("💡 To analyze bundle size: ANALYZE=true bin/shakapacker")
288-
add_info("💡 Configuration files: config/webpack/webpack.config.js, config/shakapacker.yml")
287+
288+
if bundle_analyzer_available?
289+
add_info("💡 To analyze bundle size: ANALYZE=true bin/shakapacker (opens browser)")
290+
else
291+
add_info("💡 To analyze bundle size: npm install --save-dev webpack-bundle-analyzer, then ANALYZE=true bin/shakapacker")
292+
end
293+
294+
add_info("💡 Generate stats file: bin/shakapacker --profile --json > webpack-stats.json")
295+
add_info("💡 View stats online: upload webpack-stats.json to webpack.github.io/analyse")
296+
end
297+
298+
def bundle_analyzer_available?
299+
return false unless File.exist?("package.json")
300+
301+
begin
302+
package_json = JSON.parse(File.read("package.json"))
303+
all_deps = package_json["dependencies"]&.merge(package_json["devDependencies"] || {}) || {}
304+
all_deps["webpack-bundle-analyzer"]
305+
rescue StandardError
306+
false
307+
end
289308
end
290309

291310
def check_webpack_config_content

0 commit comments

Comments
 (0)