1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Include next/dist/pages instead of exclude (patch) (#3704)

* Move security related test cases into a its own file.

* Removes the unused renderScript function

* Add a nerv example. (#3573)

* Add a nerv example.

* Fix for indentation/style

* Fix for name

* Release 5.0.0

* Add multi-zones docs. (#3688)

* Include next/dist/pages

* Fix linting
This commit is contained in:
Tim Neutkens 2018-02-06 13:09:41 +01:00 committed by Arunoda Susiripala
parent 8942d20b8c
commit f9b52cfcb6
3 changed files with 53 additions and 2 deletions

View file

@ -1,6 +1,6 @@
{
"name": "next",
"version": "5.0.0-universal-alpha.14",
"version": "5.0.0",
"description": "Minimalistic framework for server-rendered React applications",
"main": "./dist/server/next.js",
"license": "MIT",

View file

@ -44,6 +44,7 @@ Next.js is a minimalistic framework for server-rendered React applications.
- [CDN support with Asset Prefix](#cdn-support-with-asset-prefix)
- [Production deployment](#production-deployment)
- [Static HTML export](#static-html-export)
- [Multi Zones](#multi-zones)
- [Recipes](#recipes)
- [FAQ](#faq)
- [Contributing](#contributing)
@ -1220,6 +1221,48 @@ So, you could only use `pathname`, `query` and `asPath` fields of the `context`
> Basically, you won't be able to render HTML content dynamically as we pre-build HTML files. If you need that, you need run your app with `next start`.
## Multi Zones
<p><details>
<summary><b>Examples</b></summary>
<ul><li><a href="./examples/with-zones">With Zones</a></li></ul>
</details></p>
A zone is a single deployment of a Next.js app. Just like that, you can have multiple zones. Then you can merge them as a single app.
For an example, you can have two zones like this:
* https://docs.my-app.com for serving `/docs/**`
* https://ui.my-app.com for serving all other pages
With multi zones support, you can merge both these apps into a single one. Which allows your customers to browse it using a single URL. But you can develop and deploy both apps independently.
> This is exactly the same concept as microservices, but for frontend apps.
### How to define a zone
There are no special zones related APIs. You only need to do following things:
* Make sure to keep only the pages you need in your app. (For an example, https://ui.my-app.com should not contain pages for `/docs/**`)
* Make sure your app has an [assetPrefix](https://github.com/zeit/next.js#cdn-support-with-asset-prefix). (You can also define the assetPrefix [dynamically](https://github.com/zeit/next.js#dynamic-assetprefix).)
### How to merge them
You can merge zones using any HTTP proxy.
You can use [micro proxy](https://github.com/zeit/micro-proxy) as your local proxy server. It allows you to easily define routing rules like below:
```json
{
"rules": [
{"pathname": "/docs**", "method":["GET", "POST", "OPTIONS"], "dest": "https://docs.my-app.com"},
{"pathname": "/**", "dest": "https://ui.my-app.com"}
]
}
```
For the production deployment, you can use the [path alias](https://zeit.co/docs/features/path-aliases) feature if you are using [ZEIT now](https://zeit.co/now). Otherwise, you can configure your existing proxy server to route HTML pages using a set of rules as show above.
## Recipes
- [Setting up 301 redirects](https://www.raygesualdo.com/posts/301-redirects-with-nextjs/)

View file

@ -71,7 +71,15 @@ function externalsConfig (dir, isServer) {
}
// Webpack itself has to be compiled because it doesn't always use module relative paths
if (res.match(/node_modules[/\\].*\.js/) && !res.match(/node_modules[/\\]webpack/)) {
if (res.match(/node_modules[/\\]next[/\\]dist[/\\]pages/)) {
return callback()
}
if (res.match(/node_modules[/\\]webpack/)) {
return callback()
}
if (res.match(/node_modules[/\\].*\.js/)) {
return callback(null, `commonjs ${request}`)
}