From 8bccfb779ba47d57fc6e9d5d6635fe6c12e16fb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Sun, 30 Jul 2017 18:24:53 +0200 Subject: [PATCH] Nuxt start should be ready now --- build/start.js | 12 ++++++++++-- start/README.md | 43 +++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/build/start.js b/build/start.js index aa5a931879..ad8d8df4ad 100755 --- a/build/start.js +++ b/build/start.js @@ -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`) diff --git a/start/README.md b/start/README.md index ea4d75d2f8..731052c4e4 100644 --- a/start/README.md +++ b/start/README.md @@ -1,3 +1,42 @@ -# Nuxt-Start +# nuxt-start -WIP - Serve Nuxt.js Application for production \ No newline at end of file +> 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 -p -H -c +``` + +## 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 +```