DefinitelyTyped/types/webpack-plugin-serve/webpack-plugin-serve-tests.ts
Matheus Gonçalves da Silva d17c14a550 [WPS] Add changes made to static object. (#35221)
* feat: add changes to static

* fix test

* fix lint error
2019-05-06 15:36:11 -07:00

47 lines
1.1 KiB
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);
const newConfigWithGlobby = new WebpackPluginServe({
static: {
glob: ['dist/**/public'],
options: { onlyDirectories: true }
}
});