Skip to content
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

feat: allow to disable dev server #17987

Merged
merged 3 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 8 additions & 6 deletions declarations/WebpackOptions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ export type Context = string;
* References to other configurations to depend on.
*/
export type Dependencies = string[];
/**
* Options for the webpack-dev-server.
*/
export type DevServer =
| false
| {
[k: string]: any;
};
/**
* A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map).
*/
Expand Down Expand Up @@ -1055,12 +1063,6 @@ export interface FileCacheOptions {
*/
version?: string;
}
/**
* Options for the webpack-dev-server.
*/
export interface DevServer {
[k: string]: any;
}
/**
* Multiple entry bundles are created. The key is the entry name. The value can be a string, an array or an entry description object.
*/
Expand Down
7 changes: 4 additions & 3 deletions lib/config/normalization.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,10 @@ const getNormalizedWebpackOptions = config => {
),
context: config.context,
dependencies: config.dependencies,
devServer: optionalNestedConfig(config.devServer, devServer => ({
...devServer
})),
devServer: optionalNestedConfig(config.devServer, devServer => {
if (devServer === false) return false;
return { ...devServer };
}),
devtool: config.devtool,
entry:
config.entry === undefined
Expand Down
2 changes: 1 addition & 1 deletion schemas/WebpackOptions.check.js

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion schemas/WebpackOptions.json
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,16 @@
},
"DevServer": {
"description": "Options for the webpack-dev-server.",
"type": "object"
"anyOf": [
{
"description": "Disable dev server.",
"enum": [false]
},
{
"description": "Options for the webpack-dev-server.",
"type": "object"
}
]
},
"DevTool": {
"description": "A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map).",
Expand Down
16 changes: 16 additions & 0 deletions test/__snapshots__/Cli.basictest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,22 @@ Object {
"multiple": false,
"simpleType": "boolean",
},
"dev-server": Object {
"configs": Array [
Object {
"description": "Disable dev server.",
"multiple": false,
"path": "devServer",
"type": "enum",
"values": Array [
false,
],
},
],
"description": "Disable dev server.",
"multiple": false,
"simpleType": "boolean",
},
"devtool": Object {
"configs": Array [
Object {
Expand Down
9 changes: 1 addition & 8 deletions types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3240,13 +3240,6 @@ declare interface DeterministicModuleIdsPluginOptions {
*/
failOnConflict?: boolean;
}

/**
* Options for the webpack-dev-server.
*/
declare interface DevServer {
[index: string]: any;
}
declare class DllPlugin {
constructor(options: DllPluginOptions);
options: {
Expand Down Expand Up @@ -13442,7 +13435,7 @@ declare interface WebpackOptionsNormalized {
/**
* Options for the webpack-dev-server.
*/
devServer?: DevServer;
devServer?: false | { [index: string]: any };

/**
* A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map).
Expand Down