How to use nuxt - 10 common examples

To help you get started, we’ve selected a few nuxt 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 nuxt-community / nuxtent-module / test / e2e / common / nuxt.js View on Github external
const commonBefore = (nuxtentConfig, config = {}) => async () => {
  const mergedConfig = {
    ...baseConfig(nuxtentConfig),
    ...config
  }

  // Build a fresh nuxt
  nuxt = new Nuxt(mergedConfig)
  await new Builder(nuxt).build()
  await nuxt.listen(process.env.PORT)
}
github nuxt-community / nuxtent-module / test / e2e / common / nuxt.js View on Github external
const generate = (nuxtentConfig, config = {}) => async () => {
  const mergedConfig = {
    ...baseConfig(nuxtentConfig),
    ...config
  }

  // Build a fresh nuxt
  nuxt = new Nuxt(mergedConfig)
  const builder = new Builder(nuxt)
  const generator = new Generator(nuxt, builder)
  await generator.generate()
  serve()
}
github medfreeman / nuxt-netlify-cms-module / test / nuxt.js View on Github external
const generate = async (config = {}) => {
  const mergedConfig = {
    ...baseConfig,
    ...config
  };

  // Build a fresh nuxt
  nuxt = new Nuxt(mergedConfig);
  const builder = new Builder(nuxt);
  generator = new Generator(nuxt, builder);
  await generator.generate();
  serve(true);
};
github nuxt-community / electron-template / template / main.js View on Github external
/*
**  Nuxt
*/
const http = require('http')
const { Nuxt, Builder } = require('nuxt')
let config = require('./nuxt.config.js')
config.rootDir = __dirname // for electron-builder
// Init Nuxt.js
const nuxt = new Nuxt(config)
const builder = new Builder(nuxt)
const server = http.createServer(nuxt.render)
// Build only in dev mode
if (config.dev) {
	builder.build().catch(err => {
		console.error(err) // eslint-disable-line no-console
		process.exit(1)
	})
}
// Listen the server
server.listen()
const _NUXT_URL_ = `http://localhost:${server.address().port}`
console.log(`Nuxt working on ${_NUXT_URL_}`)

/*
** Electron
github surmon-china / surmon.me / server / index.js View on Github external
app.use(nuxt.render)
app.set('port', port)

const bootstrap = () => {
  server.listen(port, host)
  const appName = config.manifest.name
  const envText = isDevMode ? '开发模式' : '生产模式'
  console.info(`${appName} ${envText}启动成功!listening on ${host}:${port}, at ${new Date().toLocaleString()}`)
  // 启动扩展服务
  updateGAScript()
  barrageServer(io)
  webrtcServer(io)
}

if (config.dev) {
  new Builder(nuxt)
    .build()
    .then(bootstrap)
    .catch((error) => {
      console.error('开发模式启动失败:', error)
      process.exit(1)
    })
} else {
  bootstrap()
}
github nuxt / nuxt.js / examples / with-feathers / src / middleware / nuxt.js View on Github external
import { resolve } from 'path'
import { Nuxt, Builder } from 'nuxt'

// Setup nuxt.js
let config = {}
try {
  config = require('../../nuxt.config.js')
} catch (e) {}
config.rootDir = resolve(__dirname, '..', '..')
config.dev = process.env.NODE_ENV !== 'production'

const nuxt = new Nuxt(config)
if (config.dev) {
  const builder = new Builder(nuxt)
  builder.build().then(() => process.emit('nuxt:build:done'))
} else {
  process.nextTick(() => process.emit('nuxt:build:done'))
}

// Add nuxt.js middleware
export default function (req, res) {
  nuxt.render(req, res)
}
github binbytes / nuxt-chat-app / server / index.js View on Github external
app.use(session({
  secret: process.env.secretKey || '7CigmgctzNfojD5D3eJ7tY62axBuFICn',
  resave: false,
  saveUninitialized: false,
  cookie: { maxAge: 60000 }
}))

// Import API Routes
app.use('/api', routes)

// Import and Set Nuxt.js options
let config = require('../nuxt.config.js')
config.dev = !(process.env.NODE_ENV === 'production')

// Init Nuxt.js
const nuxt = new Nuxt(config)

// Build only in dev mode
if (config.dev) {
  const builder = new Builder(nuxt)
  builder.build()
}

// Give nuxt middleware to express
app.use(nuxt.render)

// Listen the server
// app.listen(port, host)
server.listen(port, host)
console.log('Server listening on ' + host + ':' + port) // eslint-disable-line no-console
github justyeh / nuxt.justyeh.top / server / index.js View on Github external
async function start() {
  // Import and Set Nuxt.js options
  let config = require('../nuxt.config.js')
  config.dev = !(process.env.NODE_ENV === 'production')
  // Instanciate nuxt.js
  const nuxt = new Nuxt(config)
  // Add nuxt.js middleware
  app.use(nuxt.render)
  // Listen the server
  app.listen(port, host)
  console.log('Server listening on ' + host + ':' + port) // eslint-disable-line no-console
}
github rlindskog / vueniverse / demo / src / server / index.js View on Github external
async function start () {
  config.dev = !(process.env.NODE_ENV === 'production')
  const nuxt = new Nuxt(config)
  app.use(nuxt.render)
  app.listen(process.env.PORT, process.env.HOST)
  console.log(`API listening at http://${process.env.HOST}:${process.env.PORT}/api`) // eslint-disable-line no-console
}
github michalzaq12 / electron-nuxt / template / .electron-nuxt / renderer / nuxt-process.js View on Github external
process.on('message', async ({ action, target }) => {
  if (action !== 'build') {
    console.warn('Unknown action')
    process.send({ status: 'error', err: `Nuxt process: unknown action ('${action}')` })
    return
  }

  await nuxt.ready()

  // https://github.com/nuxt/nuxt.js/blob/dev/packages/builder/src/builder.js
  const builder = new Builder(nuxt)

  // https://github.com/nuxt/nuxt.js/blob/dev/packages/generator/src/generator.js
  const generator = new Generator(nuxt, builder)

  if (target === 'development') {
    builder.build().then(() => {
      nuxt.listen(SERVER_PORT)
      process.send({ status: 'ok' })
    }).catch(err => {
      console.error(err)
      process.send({ status: 'error', err: err.message })
    })
  } else {
    generator.generate({ build: true, init: true }).then(({ errors }) => {
      if (errors.length === 0) process.send({ status: 'ok' })
      else process.send({ status: 'error', err: 'Error occurred while generating pages' })
    }).catch(err => {
      console.error(err)
      process.send({ status: 'error', err: err.message })

nuxt

Nuxt is a free and open-source framework with an intuitive and extendable way to create type-safe, performant and production-grade full-stack web applications and websites with Vue.js.

MIT
Latest version published 12 days ago

Package Health Score

83 / 100
Full package analysis