提交 5be30aae 编写于 作者: A Alejandro Garcia Anglada 提交者: Luis Alvarez D

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

上级 b6d51314
......@@ -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
```
### Download manually
### Download
Download the example:
......@@ -21,20 +21,48 @@ curl https://codeload.github.com/zeit/next.js/tar.gz/canary | tar -xz --strip=2
cd with-next-offline
```
Install it and run:
### Install dependecies
```bash
npm install
npm run dev
npm run export
serve -s out
# or
yarn
yarn dev
```
### Build
#### Static export
```bash
npm run export
# or
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))
```bash
......
......@@ -2,7 +2,9 @@ const withOffline = require('next-offline')
module.exports = withOffline({
workboxOpts: {
swDest: 'static/service-worker.js',
swDest: process.env.NEXT_EXPORT
? 'service-worker.js'
: 'static/service-worker.js',
},
experimental: {
async rewrites() {
......
......@@ -6,13 +6,15 @@
"dev": "next",
"build": "next build",
"start": "next start",
"export": "next build && next export"
"export": "cross-env NEXT_EXPORT=true next build && cross-env NEXT_EXPORT=true next export"
},
"dependencies": {
"next": "canary",
"next-offline": "4.0.6",
"react": "16.12.0",
"react-dom": "16.12.0",
"serve": "11.2.0"
"react-dom": "16.12.0"
},
"devDependencies": {
"cross-env": "6.0.3"
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册