Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
publicPath: '/.assets/',
contentBase: './ui/assets',
stats: WEBPACK_STATS_OPTIONS,
noInfo: false,
disableHostCheck: true,
proxy: {
'/': {
target: 'http://localhost:3081',
// Avoid crashing on "read ECONNRESET".
onError: err => console.error(err),
onProxyReqWs: (_proxyReq, _req, socket) =>
socket.on('error', err => console.error('WebSocket proxy error:', err)),
},
},
}
WebpackDevServer.addDevServerEntrypoints(webpackConfig, options)
const server = new WebpackDevServer(createWebpackCompiler(webpackConfig), options)
await new Promise((resolve, reject) => {
server.listen(3080, '0.0.0.0', err => (err ? reject(err) : resolve()))
})
}
modules: false,
builtAt: false,
})
.contentBase(false)
.hot(true);
const options = config.toConfig();
// webpack-chain 中没有 after 这个方法,只能这样赋值
Object.assign(options.devServer, {
after: (app, server) => {
router(app, cwd);
}
});
WebpackDevServer.addDevServerEntrypoints(options, options.devServer);
const compiler = webpack(options);
const server = new WebpackDevServer(compiler, options.devServer);
server.listen(port, '0.0.0.0', () => {
console.log();
console.log(chalk.yellow(`Starting at http://127.0.0.1:${port}`));
console.log();
});
};
publicPath: '/.assets/',
contentBase: './ui/assets',
stats: WEBPACK_STATS_OPTIONS,
noInfo: false,
disableHostCheck: true,
proxy: {
'/': {
target: 'http://localhost:3081',
// Avoid crashing on "read ECONNRESET".
onError: err => console.error(err),
onProxyReqWs: (_proxyReq, _req, socket) =>
socket.on('error', err => console.error('WebSocket proxy error:', err)),
},
},
}
addDevServerEntrypoints(webpackConfig, options)
const server = new WebpackDevServer(createWebpackCompiler(webpackConfig), options)
await new Promise((resolve, reject) => {
server.listen(3080, '0.0.0.0', (err?: Error) => (err ? reject(err) : resolve()))
})
}
}) {
if (typeof cfgExtendBase.chainWebpack === 'function') {
log(`Chaining ${name ? name + ' ' : ''}Webpack config`)
cfgExtendBase.chainWebpack(chain, invokeParams)
}
const webpackConfig = chain.toConfig()
if (typeof cfgExtendBase.extendWebpack === 'function') {
log(`Extending ${name ? name + ' ' : ''}Webpack config`)
cfgExtendBase.extendWebpack(webpackConfig, invokeParams)
}
if (hot && cfg.ctx.dev && cfg.devServer.hot) {
// tap entries for HMR
require('webpack-dev-server').addDevServerEntrypoints(webpackConfig, cfg.devServer)
}
return webpackConfig
}
quiet: false,
// Hide the build info
noInfo: false,
// Tell the server where to serve static files from.
// Set this is the `paths.js` file.
contentBase: paths.appAssets,
// If static content changes, reload the page.
// In other words, editing a photo within the assets
// directory will force the page to reload.
watchContentBase: true,
after() {
process.stdout.write(`dev server is running: http://${Host}:${Port}\n`);
},
};
WebpackDevServer.addDevServerEntrypoints(config, options);
const compiler = webpack(config);
const server = new WebpackDevServer(compiler, options);
server.listen(Port, Host, () => {});
chunks: false,
children: false,
entrypoints: false,
chunkModules: false,
source: false,
cachedAssets: false,
cached: false,
chunkOrigins: false,
modules: false,
builtAt: false,
})
.hot(true);
const options = config.toConfig();
WebpackDevServer.addDevServerEntrypoints(options, options.devServer);
const compiler = webpack(options);
const server = new WebpackDevServer(compiler, options.devServer);
server.listen(port, '0.0.0.0', () => {
console.log(' ');
console.log(chalk.yellow(`Starting at http://127.0.0.1:${port}`));
console.log(' ');
});
};
const webpack = require('webpack');
const WebpackDevServer = require('webpack-dev-server');
const opn = require('opn');
const config = require('../config/webpack.config.dev');
process.env.NODE_ENV = 'development';
const devServerOptions = config.devServer;
delete config.devServer;
const { port, host } = devServerOptions;
const url = `http://localhost:${port}/pages/content`;
WebpackDevServer.addDevServerEntrypoints(config, devServerOptions);
let isFirst = true;
const compiler = webpack(config);
compiler.plugin('done', stats => {
if (stats.hasErrors()) {
console.log(stats.toString({ colors: true }));
return;
}
if (isFirst) {
opn(url);
isFirst = false;
console.log(`Dev server listen on ${url}`);
}
});
const devServer = new WebpackDevServer(compiler, devServerOptions);
webpack(mainConfig, (err, stats) => {
if (err) {
reject(err);
} else {
resolve(stats);
}
});
});
rendererConfig.plugins.push(new webpack.HotModuleReplacementPlugin());
const devServerOptions = Object.assign({}, rendererConfig.devServer, {
stats: {
colors: true,
}
});
WebpackDevServer.addDevServerEntrypoints(rendererConfig, devServerOptions);
const rendererCompiler = webpack(rendererConfig);
const server = new WebpackDevServer(rendererCompiler, devServerOptions);
const serverPromise = new Promise((resolve, reject) => {
let port = 9000;
try {
server.listen(port, "127.0.0.1", resolve(port));
} catch (e) {
reject(e);
}
})
log.info(`Main building...`);
const stats = await mainPromise;
{
const info = stats.toJson();
ignorePath: true,
logLevel: 'error',
},
{
context: '/dev',
target: `http://${host}:${port}/eDev.html`,
ignorePath: true,
logLevel: 'error',
},
],
watchOptions: {
ignored: /node_modules/,
},
};
WebpackDevServer.addDevServerEntrypoints(config, options);
const compiler = webpack(config);
const server = new WebpackDevServer(compiler, options);
const close = () => {
server.close();
};
['SIGINT', 'SIGTERM'].forEach(signal => {
process.on(signal, close);
});
if (watcher) {
watcher.on('event', event => {
if (event.code === 'ERROR') {
server.sockWrite(server.sockets, 'errors', [event.error.stack]);
}
overlay: false,
host,
contentBase,
before (app, server) {
if (fs.existsSync(contentBase)) {
app.use(ctx.base, require('express').static(contentBase))
}
ctx.pluginAPI.options.beforeDevServer.syncApply(app, server)
},
after (app, server) {
ctx.pluginAPI.options.afterDevServer.syncApply(app, server)
}
}, ctx.siteConfig.devServer || {})
WebpackDevServer.addDevServerEntrypoints(config, serverConfig)
const compiler = webpack(config)
const server = new WebpackDevServer(compiler, serverConfig)
return {
server,
host,
port,
ctx
}
}