2021-03-28 20:14:04 +00:00
|
|
|
import { resolve } from 'path'
|
|
|
|
import { joinURL } from 'ufo'
|
|
|
|
|
|
|
|
export default {
|
2021-04-15 18:49:29 +00:00
|
|
|
/**
|
|
|
|
* Directory name that holds all the assets and generated pages for a `static` build.
|
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
dir: {
|
|
|
|
$resolve: (val = 'dist', get) => resolve(get('rootDir'), val)
|
|
|
|
},
|
2021-04-15 18:49:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The routes to generate.
|
|
|
|
*
|
|
|
|
* If you are using the crawler, this will be only the starting point for route generation.
|
|
|
|
* This is often necessary when using dynamic routes.
|
|
|
|
*
|
|
|
|
* It can be an array or a function.
|
|
|
|
*
|
|
|
|
* @example
|
|
|
|
* ```js
|
|
|
|
* routes: ['/users/1', '/users/2', '/users/3']
|
|
|
|
* ```
|
|
|
|
*
|
|
|
|
* You can pass a function that returns a promise or a function that takes a callback. It should
|
|
|
|
* return an array of strings or objects with `route` and (optional) `payload` keys.
|
|
|
|
*
|
|
|
|
* @example
|
|
|
|
* ```js
|
|
|
|
* async routes() {
|
|
|
|
* const res = await axios.get('https://my-api/users')
|
|
|
|
* return res.data.map(user => ({ route: '/users/' + user.id, payload: user }))
|
|
|
|
* }
|
|
|
|
* // or
|
|
|
|
* routes(callback) {
|
|
|
|
* axios
|
|
|
|
* .get('https://my-api/users')
|
|
|
|
* .then(res => {
|
|
|
|
* const routes = res.data.map(user => '/users/' + user.id)
|
|
|
|
* callback(null, routes)
|
|
|
|
* })
|
|
|
|
* .catch(callback)
|
|
|
|
* }
|
|
|
|
* ```
|
|
|
|
*
|
|
|
|
* If `routes()` returns a payload, it can be accessed from the Nuxt context.
|
|
|
|
* @example
|
|
|
|
* ```js
|
|
|
|
* async asyncData ({ params, error, payload }) {
|
|
|
|
* if (payload) return { user: payload }
|
|
|
|
* else return { user: await backend.fetchUser(params.id) }
|
|
|
|
* }
|
|
|
|
* ```
|
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
routes: [],
|
2021-04-15 18:49:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* An array of string or regular expressions that will prevent generation
|
|
|
|
* of routes matching them. The routes will still be accessible when `fallback` is set.
|
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
exclude: [],
|
2021-04-15 18:49:29 +00:00
|
|
|
|
|
|
|
/** The number of routes that are generated concurrently in the same thread. */
|
2021-03-28 20:14:04 +00:00
|
|
|
concurrency: 500,
|
2021-04-15 18:49:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Interval in milliseconds between two render cycles to avoid flooding a potential
|
|
|
|
* API with calls.
|
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
interval: 0,
|
2021-04-15 18:49:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set to `false` to disable creating a directory + `index.html` for each route.
|
|
|
|
*
|
|
|
|
* @example
|
|
|
|
* ```bash
|
|
|
|
* # subFolders: true
|
|
|
|
* -| dist/
|
|
|
|
* ---| index.html
|
|
|
|
* ---| about/
|
|
|
|
* -----| index.html
|
|
|
|
* ---| products/
|
|
|
|
* -----| item/
|
|
|
|
* -------| index.html
|
|
|
|
*
|
|
|
|
* # subFolders: false
|
|
|
|
* -| dist/
|
|
|
|
* ---| index.html
|
|
|
|
* ---| about.html
|
|
|
|
* ---| products/
|
|
|
|
* -----| item.html
|
|
|
|
* ```
|
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
subFolders: true,
|
2021-04-15 18:49:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The path to the fallback HTML file.
|
|
|
|
*
|
|
|
|
* Set this as the error page in your static server configuration, so that unknown
|
|
|
|
* routes can be rendered (on the client-side) by Nuxt.
|
|
|
|
*
|
|
|
|
* * If unset or set to a falsy value, the name of the fallback HTML file will be `200.html`.
|
|
|
|
* * If set to true, the filename will be `404.html`.
|
|
|
|
* * If you provide a string as a value, it will be used instead.
|
|
|
|
*
|
|
|
|
* **Note**: Multiple services (e.g. Netlify) detect a `404.html` automatically. If
|
|
|
|
* you configure your web server on your own, please consult its documentation
|
|
|
|
* to find out how to set up an error page (and set it to the 404.html file)
|
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
fallback: { $resolve: val => val === true ? '400.html' : (val || '200.html') },
|
2021-04-15 18:49:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set to `false` to disable generating pages discovered through crawling relative
|
|
|
|
* links in generated pages.
|
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
crawler: true,
|
2021-04-15 18:49:29 +00:00
|
|
|
|
|
|
|
/** Set to `false` to disable generating a `manifest.js` with a list of all generated pages. */
|
2021-03-28 20:14:04 +00:00
|
|
|
manifest: true,
|
2021-04-15 18:49:29 +00:00
|
|
|
|
|
|
|
/** Set to `false` to disable generating a `.nojekyll` file (which aids compatibility with GitHub Pages). */
|
2021-03-28 20:14:04 +00:00
|
|
|
nojekyll: true,
|
2021-04-15 18:49:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Configure the cache (used with `static` target to avoid rebuilding when no files have changed).
|
|
|
|
*
|
|
|
|
* Set to `false` to disable completely.
|
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
cache: {
|
2021-04-15 18:49:29 +00:00
|
|
|
/** An array of files or directories to ignore. (It can also be a function that returns an array.) */
|
2021-03-28 20:14:04 +00:00
|
|
|
ignore: [],
|
2021-04-15 18:49:29 +00:00
|
|
|
/**
|
|
|
|
* Options to pass to [`globby`](https://github.com/sindresorhus/globby), which
|
|
|
|
* is used to generate a 'snapshot' of the source files.
|
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
globbyOptions: {
|
|
|
|
gitignore: true
|
|
|
|
}
|
|
|
|
},
|
2021-04-15 18:49:29 +00:00
|
|
|
|
2021-03-28 20:14:04 +00:00
|
|
|
staticAssets: {
|
2021-04-15 18:49:29 +00:00
|
|
|
/** The directory underneath `/_nuxt/`, where static assets (payload, state and manifest files) will live. */
|
2021-03-28 20:14:04 +00:00
|
|
|
dir: 'static',
|
2021-04-15 18:49:29 +00:00
|
|
|
/**
|
|
|
|
* The full path to the directory underneath `/_nuxt/` where static assets
|
|
|
|
* (payload, state and manifest files) will live.
|
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
base: { $resolve: (val, get) => val || joinURL(get('app.assetsPath'), get('generate.dir')) },
|
2021-04-15 18:49:29 +00:00
|
|
|
/** The full path to the versioned directory where static assets for the current buidl are located. */
|
2021-03-28 20:14:04 +00:00
|
|
|
versionBase: { $resolve: (val, get) => val || joinURL(get('generate.base'), get('generate.version')) },
|
2021-04-15 18:49:29 +00:00
|
|
|
/** A unique string to uniquely identify payload versions (defaults to the current timestamp). */
|
2021-03-28 20:14:04 +00:00
|
|
|
version: { $resolve: val => val || (String(Math.round(Date.now() / 1000))) }
|
|
|
|
}
|
|
|
|
}
|