|
1 | 1 | declare module 'shakapacker' { |
2 | 2 | import { Configuration, RuleSetRule } from 'webpack' |
3 | | - import { Configuration as WebpackDevServerConfiguration } from 'webpack-dev-server' |
| 3 | + import * as https from 'node:https'; |
4 | 4 |
|
5 | 5 | export interface Config { |
6 | 6 | source_path: string |
@@ -33,18 +33,40 @@ declare module 'shakapacker' { |
33 | 33 | runningWebpackDevServer: boolean |
34 | 34 | } |
35 | 35 |
|
36 | | - type CamelToSnakeCase<S extends string> = S extends `${infer First}${infer Rest}` |
37 | | - ? Rest extends Uncapitalize<Rest> // Check if `Rest` starts with a lowercase letter |
38 | | - ? `${Lowercase<First>}${CamelToSnakeCase<Rest>}` |
39 | | - : `${Lowercase<First>}_${CamelToSnakeCase<Uncapitalize<Rest>>}` |
40 | | - : S |
| 36 | + type Header = Array<{ key: string; value: string }> | Record<string, string | string[]> |
| 37 | + type ServerType = 'http' | 'https' | 'spdy' |
| 38 | + type WebSocketType = 'sockjs' | 'ws' |
41 | 39 |
|
42 | | - type SnakeCase<T> = { |
43 | | - [K in keyof T as CamelToSnakeCase<string & K>]: T[K]; |
44 | | - } |
45 | | - |
46 | | - type DevServerConfig = SnakeCase<Omit<WebpackDevServerConfiguration, 'hot'>> & { |
47 | | - hmr?: boolean |
| 40 | + /** |
| 41 | + * This has the same keys and behavior as https://webpack.js.org/configuration/dev-server/ except: |
| 42 | + * 1. `hot` is replaced by `hmr`; |
| 43 | + * 2. Camel-cased properties are replaced by snake-cased ones. |
| 44 | + * @see {import('webpack-dev-server').Configuration} |
| 45 | + */ |
| 46 | + interface DevServerConfig { |
| 47 | + allowed_hosts?: 'all' | 'auto' | string | string[] |
| 48 | + bonjour?: boolean | Record<string, unknown> // bonjour.BonjourOptions |
| 49 | + client?: Record<string, unknown> // Client |
| 50 | + compress?: boolean |
| 51 | + dev_middleware?: Record<string, unknown> // webpackDevMiddleware.Options |
| 52 | + headers?: Header | (() => Header) |
| 53 | + history_api_fallback?: boolean | Record<string, unknown> // HistoryApiFallbackOptions |
| 54 | + hmr?: 'only' | boolean |
| 55 | + host?: 'local-ip' | 'local-ipv4' | 'local-ipv6' | string |
| 56 | + http2?: boolean |
| 57 | + https?: boolean | https.ServerOptions |
| 58 | + ipc?: boolean | string |
| 59 | + magic_html?: boolean |
| 60 | + live_reload?: boolean |
| 61 | + open?: boolean | string | string[] | Record<string, unknown> | Record<string, unknown>[] |
| 62 | + port?: 'auto' | string | number |
| 63 | + proxy?: unknown // ProxyConfigMap | ProxyConfigArray |
| 64 | + setup_exit_signals?: boolean |
| 65 | + static?: boolean | string | unknown // Static | Array<string | Static> |
| 66 | + watch_files?: string | string[] | unknown // WatchFiles | Array<WatchFiles | string> |
| 67 | + web_socket_server?: string | boolean | WebSocketType | { type?: string | boolean | WebSocketType, options?: Record<string, unknown> } |
| 68 | + server?: string | boolean | ServerType | { type?: string | boolean | ServerType, options?: https.ServerOptions } |
| 69 | + [otherWebpackDevServerConfigKey: string]: unknown |
48 | 70 | } |
49 | 71 |
|
50 | 72 | export const config: Config |
|
0 commit comments