Related #4659
Adds the possibility for users to copy files inside of `exportPathMap`. This allows for adding `robots.txt` `sitemap.xml` etc. another use case is for https://github.com/hanford/next-offline, currently it's manually reading the buildId in `exportPathMap`.
To allow users to do this we'll introduce a new parameter holding an object with the following keys:
- `dev` - `true` when `exportPathMap` is being called in development. `false` when running `next export`. In development `exportPathMap` is used to define routes and behavior like copying files is not required.
- `dir` - Absolute path to the project directory
- `outDir` - Absolute path to the `out` directory (configurable with `-o` or `--outdir`). When `dev` is `true` the value of `outDir` will be `null`.
- `distDir` - Absolute path to the `.next` directory (configurable using the `distDir` config key)
- `buildId` - The buildId the export is running for
Example usage:
```js
// next.config.js
const fs = require('fs')
const {join} = require('path')
const {promisify} = require('util')
const copyFile = promisify(fs.copyFile)
module.exports = {
exportPathMap: async function (defaultPathMap, {dev, dir, outDir, distDir, buildId}) {
if(dev) {
return defaultPathMap
}
// This will copy robots.txt from your project root into the out directory
await copyFile(join(dir, 'robots.txt'), join(outDir, 'robots.txt'))
return defaultPathMap
}
}
```
* Implement a very simple prefetching solution.
* Remove next-prefetcher.
* Require 'whatwg-fetch' only in the client.
* Use xhr in the code.
* Use a simple fetching solution.
* Fix 404 and xhr status issue.
* Move the prefetching implementation to next/router.
* Add deprecated warnning for next/prefetch
* Run only 2 parellel prefetching request at a time.
* Change xhr to jsonPageRes.
* Improve the prefetching logic.
* Add unit tests covering the Router.prefetch()
* Update examples to use the new syntax.
* Update docs.
* Use execOnce() to manage warn printing.
* Remove prefetcher building from the flyfile.js
Because, we no longer use it.
* Added Google AMP example
* Added styles and a second page
* Using regular anchor since there is no client-side routing
* Added comment on react config for amp
* Add minimal apollo example
* Update apollo example README
* Update apollo example demo link in README
* Fix button styles
* Fix show more button
* Alias demo url
* Include the data field on the Apollo store when hydrating
* Revert
* Include the data field on the Apollo store when hydrating per tpreusse's suggestion.
* Add example to faq section in README
* Sort by newest; Add active state to buttons
* Make optimization suggestions
* Use process.browser; inline props
* Add details to custom Document documentation
Custom document must be created at ./Pages/_document.js, which is not
noted in the README… so I updated it.
* Add note to styled-components example about existing issue
* Made phrasing a bit more clear
* Another phrasing update.
* from P to p
* added layout component example
* coding style fixes
* trailing spaces removed
* updated README file
* added layout example in docs
* moved .babelrc so that it handles all projects from the examples folder
* Move route loading logic to a common place.
* Add router events.
* Add EventEmitter's core API methods.
* Add example app for loading events and docs.
* Fix some typos.
* Get rid of Router.ready()
* Remove events package.
It's already shipping with webpack.
* Handling aborting properly.
* Expose simple attribute based events listener API.
Removed the proposed event listener API from the public API.
* Remove error logged when there's an abort error.
There are many other ways to capture this error.
So, it doesn't look nice to print this always.
* Change router events to pass only the current URL as arguments.
* Add a section about Cancelled Routes to README.