DefinitelyTyped/types/webpack-plugin-serve/webpack-plugin-serve-tests.ts
Matheus Gonçalves da Silva a4e52c5eb1 Add type definitions to webpack-plugin-serve (#33948)
* feat(wps): add webpack-plugin-serve types

* fix export method

* fix declaration

* add strictFunctionTypes

* fix declaration problems

* remove redundant declare

* add correct level types

* export history api interfaces

* reuse koa-compress and koa-static

* fix padding
2019-03-25 09:34:48 -07:00

40 lines
944 B
TypeScript

import { WebpackPluginServe } from 'webpack-plugin-serve';
import { Configuration } from 'webpack';
const usage = (config: Configuration) => {
(config.entry as string[]).push('webpack-plugin-serve/client');
config.watch = true;
config.plugins!.push(
new WebpackPluginServe({
compress: true,
historyFallback: true,
host: '0.0.0.0',
port: 3808,
liveReload: true,
middleware: (app: any, builtins: any) =>
app.use(async (ctx: any, next: any) => {
await next();
ctx.set('Access-Control-Allow-Headers', '*');
ctx.set('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
ctx.set('Access-Control-Allow-Origin', '*');
}),
static: '/',
status: true,
progress: true,
}),
);
config.output!.publicPath = '/';
return config;
};
const baseConfig = {
entry: 'index.js'
};
const configWithServer = usage(baseConfig);