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

fix(plugin-webpack): better webpack-dev-server types #2952

Merged
merged 1 commit into from
Oct 12, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/plugin/webpack/src/Config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Configuration as RawWebpackConfiguration } from 'webpack';
import WebpackDevServer from 'webpack-dev-server';
import { ConfigurationFactory as WebpackConfigurationFactory } from './WebpackConfig';

export interface WebpackPluginEntryPoint {
Expand Down Expand Up @@ -151,8 +152,7 @@ export interface WebpackPluginConfig {
* * `setupExitSignals`
* * `headers.Content-Security-Policy` (use the `devContentSecurityPolicy` config option)
*/
devServer?: Record<string, unknown>;
// TODO: use webpack-dev-server.Configuration when @types/webpack-dev-server upgrades to v4
devServer?: Omit<WebpackDevServer.Configuration, 'port' | 'static' | 'setupExitSignals' | 'Content-Security-Policy'>;
}

export type WebpackConfiguration = RawWebpackConfiguration | WebpackConfigurationFactory;
6 changes: 3 additions & 3 deletions packages/plugin/webpack/src/WebpackPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ the generated files). Instead, it is ${JSON.stringify(pj.main)}`);
const compiler = webpack(config);
const webpackDevServer = new WebpackDevServer(this.devServerOptions(), compiler);
await webpackDevServer.start();
this.servers.push(webpackDevServer.server);
this.servers.push(webpackDevServer.server!);
});

await asyncOra('Compiling Preload Scripts', async () => {
Expand Down Expand Up @@ -365,14 +365,14 @@ the generated files). Instead, it is ${JSON.stringify(pj.main)}`);
const cspDirectives =
this.config.devContentSecurityPolicy ?? "default-src 'self' 'unsafe-inline' data:; script-src 'self' 'unsafe-eval' 'unsafe-inline' data:";

const defaults = {
const defaults: Partial<WebpackDevServer.Configuration> = {
hot: true,
devMiddleware: {
writeToDisk: true,
},
historyApiFallback: true,
};
const overrides = {
const overrides: Partial<WebpackDevServer.Configuration> = {
port: this.port,
setupExitSignals: true,
static: path.resolve(this.baseDir, 'renderer'),
Expand Down
14 changes: 0 additions & 14 deletions typings/webpack-dev-server/index.d.ts

This file was deleted.