Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const addServePlugin = (type: ConfigPrefix): PresetMergeAsyncFn => async (
base,
config
) => {
const { host, devPorts } = await config.server;
const port = devPorts[type];
await killPort(port, 'tcp');
return webpackMerge(base, {
entry: {
[`${type}/hmr`]: ['webpack-plugin-serve/client'],
},
plugins: [
new WebpackPluginServe({
static: base.output.path,
client: {
address: `${host}:${port}`,
silent: true,
},
// TODO:
// this injects quite a bit UI I don't like, would love to build something custom based on this
// https://github.com/shellscape/webpack-plugin-serve/blob/master/lib/client/client.js
status: true,
global.stop = function () {
server.close()
kill(global.PORT)
}
const handleClear = async () => {
await killPort(port);
log(`Clear process running on port ${port}`);
};