Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Object.assign(config, {
mode: 'development',
entry: './demo/demo.js',
externals: [],
});
const compiler = webpack(config);
const ifaces = os.networkInterfaces();
let lookupIpAddress = null;
Object.values(ifaces).forEach(item => {
const target = item.find(details => details.family === 'IPv4');
if (target) {
lookupIpAddress = target.address;
}
});
const app = superstatic({
host: lookupIpAddress,
port: 8080,
});
compiler.watch({
// Example watchOptions
aggregateTimeout: 300,
poll: undefined,
}, (err, stats) => {
if (err || stats.hasErrors()) {
console.log('Error!');
if (err && err.details) {
console.error(err.details);
}
}
});
function startStaticWebServer(done) {
fs.writeFileSync(pidFile, process.pid);
const config = jsonfile.readFileSync(
path.join(modulePath, 'configs/superstatic.json')
);
let customConfig;
try {
customConfig = jsonfile.readFileSync(
path.join(projectPath, 'configs/static.json')
);
delete customConfig.public;
} catch (e) {
//
}
staticWebServer
.server({
port: serverPort,
host: serverHost,
cwd: projectPath,
config: Object.assign({}, config, customConfig),
errorPage:
process.env.WEBCUBE_STATIC_SERVER_ERROR_PAGE ||
path.join(modulePath, 'templates/configs/404.html'),
debug: Boolean(process.env.WEBCUBE_STATIC_SERVER_ENABLE_DEBUG),
gzip: Boolean(process.env.WEBCUBE_STATIC_SERVER_ENABLE_GZIP),
})
.listen(() => {
console.info(`Listening at http://${serverHost}:${serverPort}`);
done();
});
}
function _startServer(options, config, port, init) {
var server = superstatic({
debug: true,
port: port,
host: options.host,
config: config,
cwd: detectProjectRoot(options.cwd),
stack: "strict",
before: {
files: initMiddleware(init),
},
rewriters: {
function: functionsProxy(options),
},
}).listen(function() {
var siteName = config.target || config.site;
var label = siteName ? "hosting[" + siteName + "]" : "hosting";