mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
a8a97b07c7
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 } } ``` |
||
---|---|---|
.. | ||
index.js |