Nuxt start should be ready now

This commit is contained in:
Sébastien Chopin 2017-07-30 18:24:53 +02:00
parent 222c737a1d
commit 8bccfb779b
2 changed files with 51 additions and 4 deletions

View File

@ -1,5 +1,7 @@
#!/usr/bin/env node
const now = Date.now()
const { readFileSync, readJSONSync, writeFileSync, copySync, removeSync } = require('fs-extra')
const { resolve, relative } = require('path')
@ -38,7 +40,7 @@ requires = requires.filter(r => excludes.indexOf(r) === -1)
let dependencies = {}
requires.forEach(r => {
if (!packageJSON.dependencies[r]) {
console.warn('cannot resolve dependency version for ' + r)
console.warn('Cannot resolve dependency version for ' + r)
return
}
dependencies[r] = packageJSON.dependencies[r]
@ -81,6 +83,7 @@ const extraFiles = [
'bin/nuxt-build',
'bin/nuxt-generate',
'bin/nuxt-dev',
'bin/nuxt',
'dist/nuxt.js',
'dist/nuxt.js.map'
]
@ -92,4 +95,9 @@ extraFiles.forEach(file => {
const startIndexjs = resolve(startDir, 'index.js')
writeFileSync(startIndexjs, String(readFileSync(startIndexjs)).replace('./dist/nuxt', './dist/core'))
console.log('generated ' + packageJSON.name + '@' + packageJSON.version)
// Patch bin/nuxt-start
const binStart = resolve(startDir, 'bin/nuxt-start')
writeFileSync(binStart, String(readFileSync(binStart)).replace(/nuxt start/g, 'nuxt-start'))
const ms = Date.now() - now
console.log(`Generated ${packageJSON.name}@${packageJSON.version} in ${ms}ms`)

View File

@ -1,3 +1,42 @@
# Nuxt-Start
# nuxt-start
WIP - Serve Nuxt.js Application for production
> Start Nuxt.js Application in production mode.
## Installation
```bash
npm install --save nuxt-start
````
Add/Update your "start" script into your `package.json`:
```json
{
"scripts": {
"start": "nuxt-start"
}
}
```
## Usage
```bash
nuxt-start <dir> -p <port number> -H <hostname> -c <config file>
```
## Programmatic Usage
```js
const { Nuxt } = require('nuxt-start')
// Require nuxt config
const config = require('./nuxt.config.js')
// Create a new nuxt instance
const nuxt = new Nuxt(config)
// Start nuxt.js server
nuxt.listen(3000) // nuxt.listen(port, host)
// Or use `nuxt.render` as an express middleware
```