feat: add devServer option

BREAKING CHANGE: remove `port` option, use `devServer` option instead
This commit is contained in:
Sergey Krylov 2024-04-03 06:27:19 +03:00 committed by ksv741
parent 11fc2d47a7
commit 8246f41dde
2 changed files with 5 additions and 3 deletions

View File

@ -115,11 +115,12 @@ const createConfig = (params?: WebpackOptions): webpack.Configuration => {
analyze = false, analyze = false,
mainLoader, mainLoader,
svgLoader, svgLoader,
port = 3000,
devtool = 'inline-source-map', devtool = 'inline-source-map',
plugins, plugins,
loaders, loaders,
devServer,
} = params ?? {}; } = params ?? {};
const { const {
assets, assets,
html, html,
@ -135,7 +136,6 @@ const createConfig = (params?: WebpackOptions): webpack.Configuration => {
analyze, analyze,
mainLoader, mainLoader,
svgLoader, svgLoader,
port,
paths: { paths: {
assets, assets,
html, html,
@ -147,6 +147,7 @@ const createConfig = (params?: WebpackOptions): webpack.Configuration => {
}, },
plugins, plugins,
loaders, loaders,
devServer,
}; };
const isDev = mode === 'development'; const isDev = mode === 'development';

View File

@ -217,7 +217,6 @@ declare namespace BabelLoader {
type WebpackOptions = { type WebpackOptions = {
mode: WebpackMode; mode: WebpackMode;
paths: WebpackPaths; paths: WebpackPaths;
port: number;
mainLoader?: WebpackMainLoaders; mainLoader?: WebpackMainLoaders;
svgLoader?: 'inline' | 'svgr'; svgLoader?: 'inline' | 'svgr';
analyze: boolean; analyze: boolean;
@ -233,6 +232,7 @@ type WebpackOptions = {
copyPlugin?: CopyPlugin.PluginOptions | 'off'; copyPlugin?: CopyPlugin.PluginOptions | 'off';
ignorePlugin?: ConstructorParameters<typeof webpack.IgnorePlugin>[0] | 'off'; ignorePlugin?: ConstructorParameters<typeof webpack.IgnorePlugin>[0] | 'off';
analyzerPlugin?: BundleAnalyzerPlugin.Options | 'off'; analyzerPlugin?: BundleAnalyzerPlugin.Options | 'off';
providePlugin?: ConstructorParameters<typeof webpack.ProvidePlugin>[0] | 'off';
}; };
loaders?: { loaders?: {
esbuildLoader?: EsbuildLoaderOptions | 'off'; esbuildLoader?: EsbuildLoaderOptions | 'off';
@ -256,6 +256,7 @@ type WebpackOptions = {
}; };
}; };
cache?: webpack.Configuration['cache'] | 'off'; cache?: webpack.Configuration['cache'] | 'off';
devServer?: webpack.Configuration['devServer'];
}; };
type WebpackEnv = { type WebpackEnv = {