mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
fix(with-pkg): update pkg config for next.js (#4307)
* fix(with-pkg): update pkg config for next.js * update docs
This commit is contained in:
parent
596bd21e33
commit
4b95725e09
|
@ -21,14 +21,18 @@ curl https://codeload.github.com/zeit/next.js/tar.gz/canary | tar -xz --strip=2
|
||||||
cd with-pkg
|
cd with-pkg
|
||||||
```
|
```
|
||||||
|
|
||||||
Install it and run:
|
Install it and run pkg:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install
|
npm install
|
||||||
npm run dev
|
yarn run build
|
||||||
# or
|
yarn run dist
|
||||||
yarn
|
```
|
||||||
yarn dev
|
|
||||||
|
Execute the binary file:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
PORT=4000 ./dist/with-pkg-macos
|
||||||
```
|
```
|
||||||
|
|
||||||
Deploy it to the cloud with [now](https://zeit.co/now) ([download](https://zeit.co/download))
|
Deploy it to the cloud with [now](https://zeit.co/now) ([download](https://zeit.co/download))
|
||||||
|
@ -39,6 +43,6 @@ now
|
||||||
|
|
||||||
## The idea behind the example
|
## The idea behind the example
|
||||||
|
|
||||||
This example demostrate how you can use [pkg](https://github.com/zeit/pkg) to create a binary version of a Next.js application.
|
This example demonstrate how you can use [pkg](https://github.com/zeit/pkg) to create a binary version of a Next.js application.
|
||||||
|
|
||||||
To do it we need to create at least a super simple custom server that allow us to run `node server.js` instead of `next` or `next start`. We also need to create a `index.js` that works as the entry point for **pkg**, in that file we force to set NODE_ENV as production.
|
To do it we need to create at least a super simple custom server that allow us to run `node server.js` instead of `next` or `next start`. We also need to create a `index.js` that works as the entry point for **pkg**, in that file we force to set NODE_ENV as production.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "with-pkg",
|
"name": "with-pkg",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"main": "index.js",
|
"bin": "index.js",
|
||||||
"author": "Sergio Daniel Xalambrí <sergiodxa@gmail.com>",
|
"author": "Sergio Daniel Xalambrí <sergiodxa@gmail.com>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -10,7 +10,7 @@
|
||||||
"prestart": "npm run build",
|
"prestart": "npm run build",
|
||||||
"start": "NODE_ENV=production node server.js",
|
"start": "NODE_ENV=production node server.js",
|
||||||
"predist": "npm run build",
|
"predist": "npm run build",
|
||||||
"dist": "pkg index.js --out-dir dist"
|
"dist": "pkg . --out-dir dist"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"next": "latest",
|
"next": "latest",
|
||||||
|
@ -22,8 +22,7 @@
|
||||||
},
|
},
|
||||||
"pkg": {
|
"pkg": {
|
||||||
"assets": [
|
"assets": [
|
||||||
".next",
|
".next/**/*"
|
||||||
"pages"
|
|
||||||
],
|
],
|
||||||
"scripts": [
|
"scripts": [
|
||||||
".next/dist/**/*.js"
|
".next/dist/**/*.js"
|
||||||
|
|
|
@ -4,7 +4,7 @@ const next = require('next')
|
||||||
|
|
||||||
const port = parseInt(process.env.PORT, 10) || 3000
|
const port = parseInt(process.env.PORT, 10) || 3000
|
||||||
const dev = process.env.NODE_ENV !== 'production'
|
const dev = process.env.NODE_ENV !== 'production'
|
||||||
const app = next({ dev })
|
const app = next({ dev, dir: __dirname })
|
||||||
const handle = app.getRequestHandler()
|
const handle = app.getRequestHandler()
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
|
|
Loading…
Reference in a new issue