Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function startDevServer (directory, port = 3000) {
let url
const app = express()
const { reload } = reloadServer(app)
let preview = ''
app.get('/', (req, res) => res.send(preview))
app.use(express.static(directory))
function update ({ html, errors, metadata }) {
let status = errors.length ? chalk.red('failed') : chalk.green('success')
preview = errors.length
? buildErrorPage(errors)
: html.replace('', '')
renderCLI({ url, status, time: metadata.time, size: metadata.size })
reload()
}
return new Promise((resolve, reject) => {
import { renderToString } from 'react-dom/server'
import { ServerStyleSheets, ThemeProvider } from '@material-ui/core/styles'
import express from 'express'
import reload from 'reload'
import App from './Components/App'
import theme from './theme'
const app = express()
const port = 3000
const dev = process.env.NODE_ENV === 'development'
app.use(express.static('public'))
if (dev) {
reload(app)
}
app.use((req, res) => {
const sheets = new ServerStyleSheets()
const html = renderToString(
sheets.collect(
)
)
const css = sheets.toString()
res.send(`