How to use reload - 2 common examples

To help you get started, we’ve selected a few reload examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SparkPost / heml / packages / heml / src / bin / commands / develop.js View on Github external
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) => {
github alex996 / react-exercises / src / server.js View on Github external
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(`

reload

Node.js module to refresh and reload your code in your browser when your code changes. No browser plugins required.

MIT
Latest version published 3 months ago

Package Health Score

75 / 100
Full package analysis

Popular reload functions