Skip to content

Commit

Permalink
feat: allow to set false for dev server
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Jan 23, 2024
2 parents 81623b6 + 818b8ec commit 2d6f5fa
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 19 deletions.
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 @@ -13447,7 +13440,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

0 comments on commit 2d6f5fa

Please sign in to comment.