Fix webpack-dev-server static config: default to false, fix YAML passthrough#1032
Fix webpack-dev-server static config: default to false, fix YAML passthrough#1032
Conversation
WalkthroughDefaults and YAML handling for webpack-dev-server Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR fixes three real bugs in Shakapacker's webpack-dev-server Key findings:
Confidence Score: 5/5Safe to merge — the core bug fixes are correct and all remaining findings are P2 style/edge-case suggestions. Both open findings are P2: the CHANGELOG placeholder is a trivial text fix, and the silent drop of non-object
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[createDevServerConfig called] --> B[Build base config\nstatic: false]
B --> C{devServerYamlConfig.static\n!== undefined?}
C -- No --> F[Keep static: false]
C -- Yes --> D{static === false?}
D -- Yes --> E[config.static = false]
D -- No --> G{typeof static === 'object'\n&& static !== null?}
G -- Yes --> H[config.static = static object]
G -- No --> I[⚠️ Silently ignored\nconfig.static stays false\ne.g. static: true or string]
E --> J[delete devServerYamlConfig.static]
H --> J
I --> J
F --> K[Process remaining YAML keys\nsnake_case to camelCase]
J --> K
K --> L[Return WebpackDevServerConfig]
Reviews (1): Last reviewed commit: "docs: update changelog with PR number" | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2645056893
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
ReviewThe fix is well-motivated and the root-cause analysis is solid. Defaulting One correctness issue to address:
Everything else looks good:
|
ReviewThe fix is well-motivated and the core change is correct: One real issue:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@package/webpackDevServerConfig.ts`:
- Around line 104-114: The file is missing a trailing newline and the
devServerYamlConfig.static handling only accounts for false and object types;
update the code to add a final newline and to set config.static when
devServerYamlConfig.static is a string or array (e.g., if typeof === "string"
assign the string, if Array.isArray assign the array cast to Array<string |
Record<string, unknown>>), keeping the existing false and object branches and
still deleting devServerYamlConfig.static afterwards; also update the
WebpackDevServerConfig.static type definition (the static property in the config
interface) to include string and Array<string | object> variants so the types
align with webpack-dev-server API.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 5796f134-083b-442b-855a-214624d3508d
📒 Files selected for processing (4)
CHANGELOG.mdlib/install/config/shakapacker.ymlpackage/webpackDevServerConfig.tstest/package/webpackDevServerConfig.test.js
💤 Files with no reviewable changes (1)
- lib/install/config/shakapacker.yml
Documents expected behavior for static config: default to false, pass through YAML static: false, and pass through static objects. Some tests fail against current code — fixes follow in next commits. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Three bugs fixed:
1. Default static changed from { publicPath: contentBase } to false.
The old default set static.publicPath to a filesystem path (config.outputPath)
instead of a URL path, and never set static.directory, causing
webpack-dev-server to watch the entire public/ directory unnecessarily.
In Rails apps, static file serving is handled by ActionDispatch::Static,
not webpack-dev-server.
2. The truthy check 'if (devServerYamlConfig.static)' now uses
'if (devServerYamlConfig.static !== undefined)' so that setting
static: false in shakapacker.yml is no longer silently ignored.
3. When a user provides a static object in YAML, it is passed through
directly instead of being merged with the (now-removed) buggy base.
Also removes static.watch from the default shakapacker.yml template,
since static is now false by default and the watch config was only
needed to work around the old buggy static default.
Fixes #1031
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2645056 to
e7a1417
Compare
ReviewThis is a solid, focused fix for a real pain point. The root cause analysis is correct: the old What is good
One issue to address See the inline comment on lines 104–113 of Minor nit The test for "passes through static: false from YAML config" is technically redundant with the default test (the default is already |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e7a1417458
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
ReviewThe fix is correct and well-motivated. The old default ( Bug: unhandled truthy non-object When Minor: one test does not cover the logic it implies The test "passes through static: false from YAML config" sets Everything else looks good
|
ReviewThe fix is well-motivated and the core logic is sound. The three bugs (wrong default, Two issues to address before merging: 1. TypeScript type doesn't cover The 2. Off-by-one indentation in the A stray space gives the closing Everything else looks good:
|
… them If a user sets static: true, a string, or any other value in shakapacker.yml, pass it through to webpack-dev-server as-is instead of silently discarding it.
3f975a9 to
2c4bedd
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2c4bedd784
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
Overall: solid fix for a real bug. The truthy-check correction and false default are correct. One type-safety issue to address: see inline comments. |
- Type now accepts boolean | string | string[] | object (matching webpack-dev-server's actual schema) instead of just false | object - Bare `static:` in YAML (parses as null via js-yaml) is now treated the same as undefined — skipped, default false sticks
ReviewThe fix is correct and well-motivated. Defaulting A few nits/issues to address: 1. Redundant
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0083f34f51
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Review: Fix webpack-dev-server static configThe approach is correct and the fix addresses real bugs. A few observations: The core fix is sound
Minor issues flagged inlineSee inline comments for specifics on a redundant code branch and a test that doesn't actually verify the fix it describes. |
Summary
Fixes three bugs in Shakapacker's webpack-dev-server
staticconfiguration that cause unnecessary inotify watches and ENOSPC crashes on systems with limited headroom.staticfrom a misconfigured object tofalse— Rails servespublic/viaActionDispatch::Static, webpack-dev-server doesn't need toif (devServerYamlConfig.static)truthy check sostatic: falseinshakapacker.ymlis no longer silently ignoredstatic.watchfrom the default install template — it was a v3→v4 migration artifact that caused webpack-dev-server to watchpublic/via chokidarstaticvalues (true, strings, arrays, objects) from YAML — if a user explicitly overrides the default, we respect itFixes #1031
Details
The old default set
static.publicPathto a filesystem path (config.outputPath) instead of a URL path, and never setstatic.directory, causing webpack-dev-server to default to watching the entirepublic/directory. This has been present since v6.0.0-rc.7 but was harmless on most systems. On systems near their inotify watch limit (e.g., Fedora with auto-calculated limits + watch-heavy tools like Warp terminal), it triggersENOSPC: System limit for number of file watchers reached.Setting
static: falseis safe because:Shakapacker::DevServerProxy(hardwired in the railtie) proxies/packs/*to webpack-dev-server — the browser never accesses webpack-dev-server directlydevMiddleware, which is independent ofstaticActionDispatch::Staticservespublic/files in RailsUsers who explicitly set
staticinshakapacker.yml(totrue, an object, a string path, etc.) will have their value passed through to webpack-dev-server as-is. Barestatic:(YAML null) is treated the same as unset — the defaultfalseapplies.Test plan
test/package/webpackDevServerConfig.test.jscovering default behavior,false/true/string/object passthrough, and existing key mappingdev_server)yarn lint— 0 errorsyarn type-check— clean🤖 Generated with Claude Code