Commit 5be30aae authored by Alejandro Garcia Anglada's avatar Alejandro Garcia Anglada Committed by Luis Alvarez D

Support static export and server hosted build and update docs (#9783)

parent b6d51314
...@@ -12,7 +12,7 @@ npx create-next-app --example with-next-offline with-next-offline-app ...@@ -12,7 +12,7 @@ npx create-next-app --example with-next-offline with-next-offline-app
yarn create next-app --example with-next-offline with-next-offline-app yarn create next-app --example with-next-offline with-next-offline-app
``` ```
### Download manually ### Download
Download the example: Download the example:
...@@ -21,20 +21,48 @@ curl https://codeload.github.com/zeit/next.js/tar.gz/canary | tar -xz --strip=2 ...@@ -21,20 +21,48 @@ curl https://codeload.github.com/zeit/next.js/tar.gz/canary | tar -xz --strip=2
cd with-next-offline cd with-next-offline
``` ```
Install it and run: ### Install dependecies
```bash ```bash
npm install npm install
npm run dev
npm run export
serve -s out
# or # or
yarn yarn
yarn dev ```
### Build
#### Static export
```bash
npm run export
# or
yarn export yarn export
serve -s out
``` ```
To serve it yourself, you can run:
```bash
npx serve -s out
```
#### Server hosted
```bash
npm run build
# or
yarn build
```
To serve it yourself, run:
```bash
npm start
# or
yarn start
```
### Deploy
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))
```bash ```bash
......
...@@ -2,7 +2,9 @@ const withOffline = require('next-offline') ...@@ -2,7 +2,9 @@ const withOffline = require('next-offline')
module.exports = withOffline({ module.exports = withOffline({
workboxOpts: { workboxOpts: {
swDest: 'static/service-worker.js', swDest: process.env.NEXT_EXPORT
? 'service-worker.js'
: 'static/service-worker.js',
}, },
experimental: { experimental: {
async rewrites() { async rewrites() {
......
...@@ -6,13 +6,15 @@ ...@@ -6,13 +6,15 @@
"dev": "next", "dev": "next",
"build": "next build", "build": "next build",
"start": "next start", "start": "next start",
"export": "next build && next export" "export": "cross-env NEXT_EXPORT=true next build && cross-env NEXT_EXPORT=true next export"
}, },
"dependencies": { "dependencies": {
"next": "canary", "next": "canary",
"next-offline": "4.0.6", "next-offline": "4.0.6",
"react": "16.12.0", "react": "16.12.0",
"react-dom": "16.12.0", "react-dom": "16.12.0"
"serve": "11.2.0" },
"devDependencies": {
"cross-env": "6.0.3"
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment