-
-
Notifications
You must be signed in to change notification settings - Fork 104
Fix webpack-dev-server static config: default to false, fix YAML passthrough #1032
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ihabadham
wants to merge
8
commits into
main
Choose a base branch
from
ihabadham/fix/static-config-bugs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+133
−18
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1ec1e65
test: add tests for webpackDevServerConfig static handling
ihabadham 1e60e04
fix: default static to false and fix YAML static: false passthrough
ihabadham 9d5734e
docs: add changelog entry for static config fix
ihabadham e7a1417
docs: update changelog with PR number
ihabadham 1e6544c
style: fix Prettier formatting in test file
ihabadham 2c4bedd
fix: pass through all YAML static values instead of silently dropping…
ihabadham 0083f34
fix: widen static type to match webpack-dev-server API, handle null
ihabadham 6230078
test: add string passthrough test for static config
ihabadham File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| const { chdirTestApp, resetEnv } = require("../helpers") | ||
|
|
||
| const rootPath = process.cwd() | ||
| chdirTestApp() | ||
|
|
||
| describe("webpackDevServerConfig", () => { | ||
| beforeEach(() => { | ||
| jest.resetModules() | ||
| resetEnv() | ||
| process.env.NODE_ENV = "development" | ||
| process.env.RAILS_ENV = "development" | ||
| }) | ||
| afterAll(() => process.chdir(rootPath)) | ||
|
|
||
| test("defaults static to false", () => { | ||
| const createDevServerConfig = require("../../package/webpackDevServerConfig") | ||
| const config = createDevServerConfig() | ||
|
|
||
| expect(config.static).toBe(false) | ||
| }) | ||
|
|
||
| test("passes through static: false from YAML config", () => { | ||
| const devServer = require("../../package/dev_server") | ||
| devServer.static = false | ||
|
|
||
| const createDevServerConfig = require("../../package/webpackDevServerConfig") | ||
| const config = createDevServerConfig() | ||
|
|
||
| expect(config.static).toBe(false) | ||
ihabadham marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }) | ||
ihabadham marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| test("passes through static: true from YAML config", () => { | ||
| const devServer = require("../../package/dev_server") | ||
| devServer.static = true | ||
|
|
||
| const createDevServerConfig = require("../../package/webpackDevServerConfig") | ||
| const config = createDevServerConfig() | ||
|
|
||
| expect(config.static).toBe(true) | ||
| }) | ||
|
|
||
| test("passes through static string path from YAML config", () => { | ||
| const devServer = require("../../package/dev_server") | ||
| devServer.static = "/custom/static" | ||
|
|
||
| const createDevServerConfig = require("../../package/webpackDevServerConfig") | ||
| const config = createDevServerConfig() | ||
|
|
||
| expect(config.static).toBe("/custom/static") | ||
| }) | ||
|
|
||
| test("passes through static object from YAML config", () => { | ||
| const devServer = require("../../package/dev_server") | ||
| devServer.static = { directory: "/custom/path", watch: false } | ||
|
|
||
| const createDevServerConfig = require("../../package/webpackDevServerConfig") | ||
| const config = createDevServerConfig() | ||
|
|
||
| expect(config.static).toStrictEqual({ | ||
| directory: "/custom/path", | ||
| watch: false | ||
| }) | ||
| }) | ||
ihabadham marked this conversation as resolved.
Show resolved
Hide resolved
ihabadham marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| test("sets devMiddleware.publicPath to URL path", () => { | ||
| const createDevServerConfig = require("../../package/webpackDevServerConfig") | ||
| const config = createDevServerConfig() | ||
|
|
||
| expect(config.devMiddleware.publicPath).toBe("/packs/") | ||
| }) | ||
|
|
||
| test("maps hmr to hot", () => { | ||
| const createDevServerConfig = require("../../package/webpackDevServerConfig") | ||
| const config = createDevServerConfig() | ||
|
|
||
| expect(config.hot).toBe(true) | ||
| expect(config.hmr).toBeUndefined() | ||
| }) | ||
|
|
||
| test("defaults liveReload to inverse of hmr", () => { | ||
| const createDevServerConfig = require("../../package/webpackDevServerConfig") | ||
| const config = createDevServerConfig() | ||
|
|
||
| // Test app has hmr: true, so liveReload should default to false | ||
| expect(config.liveReload).toBe(false) | ||
| }) | ||
|
|
||
| test("maps snake_case YAML keys to camelCase webpack-dev-server keys", () => { | ||
| const devServer = require("../../package/dev_server") | ||
| devServer.allowed_hosts = "auto" | ||
|
|
||
| const createDevServerConfig = require("../../package/webpackDevServerConfig") | ||
| const config = createDevServerConfig() | ||
|
|
||
| expect(config.allowedHosts).toBe("auto") | ||
| expect(config.allowed_hosts).toBeUndefined() | ||
| }) | ||
|
|
||
| test("passes through client config", () => { | ||
| const devServer = require("../../package/dev_server") | ||
| devServer.client = { overlay: true } | ||
|
|
||
| const createDevServerConfig = require("../../package/webpackDevServerConfig") | ||
| const config = createDevServerConfig() | ||
|
|
||
| expect(config.client).toStrictEqual({ overlay: true }) | ||
| }) | ||
| }) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.