2021-09-27 12:49:36 +00:00
|
|
|
import { resolve, join } from 'pathe'
|
2021-03-28 20:14:04 +00:00
|
|
|
import { existsSync, readdirSync } from 'fs'
|
|
|
|
import defu from 'defu'
|
|
|
|
import { isRelative, joinURL, hasProtocol } from 'ufo'
|
|
|
|
|
|
|
|
export default {
|
2021-04-15 18:49:29 +00:00
|
|
|
/** Vue.js config */
|
2021-03-28 20:14:04 +00:00
|
|
|
vue: {
|
2021-04-15 18:49:29 +00:00
|
|
|
/**
|
|
|
|
* Properties that will be set directly on `Vue.config` for vue@2 and `app.config` for vue@3.
|
|
|
|
*
|
|
|
|
* @see [vue@2 Documentation](https://vuejs.org/v2/api/#Global-Config)
|
|
|
|
* @see [vue@3 Documentation](https://v3.vuejs.org/api/application-config.html)
|
2021-08-11 21:48:33 +00:00
|
|
|
* @version 2
|
2021-04-15 18:49:29 +00:00
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
config: {
|
2021-07-31 20:26:41 +00:00
|
|
|
silent: { $resolve: (val, get) => val ?? !get('dev') },
|
2021-03-28 20:14:04 +00:00
|
|
|
performance: { $resolve: (val, get) => val ?? get('dev') }
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2021-04-15 18:49:29 +00:00
|
|
|
/**
|
|
|
|
* Nuxt App configuration.
|
2021-08-11 21:48:33 +00:00
|
|
|
* @version 2
|
2021-04-15 18:49:29 +00:00
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
app: {
|
|
|
|
$resolve: (val, get) => {
|
|
|
|
const useCDN = hasProtocol(get('build.publicPath'), true) && !get('dev')
|
|
|
|
const isRelativePublicPath = isRelative(get('build.publicPath'))
|
|
|
|
return defu(val, {
|
|
|
|
basePath: get('router.base'),
|
|
|
|
assetsPath: isRelativePublicPath ? get('build.publicPath') : useCDN ? '/' : joinURL(get('router.base'), get('build.publicPath')),
|
|
|
|
cdnURL: useCDN ? get('build.publicPath') : null
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2021-04-15 18:49:29 +00:00
|
|
|
* The path to a templated HTML file for rendering Nuxt responses.
|
|
|
|
* Uses `<srcDir>/app.html` if it exists or the Nuxt default template if not.
|
|
|
|
*
|
|
|
|
* @example
|
|
|
|
* ```html
|
|
|
|
* <!DOCTYPE html>
|
|
|
|
* <html {{ HTML_ATTRS }}>
|
|
|
|
* <head {{ HEAD_ATTRS }}>
|
|
|
|
* {{ HEAD }}
|
|
|
|
* </head>
|
|
|
|
* <body {{ BODY_ATTRS }}>
|
|
|
|
* {{ APP }}
|
|
|
|
* </body>
|
|
|
|
* </html>
|
|
|
|
* ```
|
2021-08-11 21:48:33 +00:00
|
|
|
* @version 2
|
2021-03-28 20:14:04 +00:00
|
|
|
*/
|
|
|
|
appTemplatePath: {
|
|
|
|
$resolve: (val, get) => {
|
|
|
|
if (val) {
|
|
|
|
return resolve(get('srcDir'), val)
|
|
|
|
}
|
|
|
|
if (existsSync(join(get('srcDir'), 'app.html'))) {
|
|
|
|
return join(get('srcDir'), 'app.html')
|
|
|
|
}
|
|
|
|
return resolve(get('buildDir'), 'views/app.template.html')
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2021-04-15 18:49:29 +00:00
|
|
|
/**
|
|
|
|
* Enable or disable vuex store.
|
2021-08-11 21:48:33 +00:00
|
|
|
*
|
|
|
|
* By default it is enabled if there is a `store/` directory
|
|
|
|
* @version 2
|
2021-04-15 18:49:29 +00:00
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
store: {
|
|
|
|
$resolve: (val, get) => val !== false &&
|
|
|
|
existsSync(join(get('srcDir'), get('dir.store'))) &&
|
|
|
|
readdirSync(join(get('srcDir'), get('dir.store')))
|
|
|
|
.find(filename => filename !== 'README.md' && filename[0] !== '.')
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2021-04-15 18:49:29 +00:00
|
|
|
* Options to pass directly to `vue-meta`.
|
|
|
|
*
|
|
|
|
* @see [documentation](https://vue-meta.nuxtjs.org/api/#plugin-options).
|
2021-08-11 21:48:33 +00:00
|
|
|
* @version 2
|
2021-03-28 20:14:04 +00:00
|
|
|
*/
|
|
|
|
vueMeta: null,
|
|
|
|
|
2021-04-15 18:49:29 +00:00
|
|
|
/**
|
|
|
|
* Set default configuration for `<head>` on every page.
|
|
|
|
*
|
|
|
|
* @see [documentation](https://vue-meta.nuxtjs.org/api/#metainfo-properties) for specifics.
|
2021-08-11 21:48:33 +00:00
|
|
|
* @version 2
|
2021-04-15 18:49:29 +00:00
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
head: {
|
2021-08-11 21:48:33 +00:00
|
|
|
/** Each item in the array maps to a newly-created `<meta>` element, where object properties map to attributes. */
|
2021-03-28 20:14:04 +00:00
|
|
|
meta: [],
|
2021-08-11 21:48:33 +00:00
|
|
|
/** Each item in the array maps to a newly-created `<link>` element, where object properties map to attributes. */
|
2021-03-28 20:14:04 +00:00
|
|
|
link: [],
|
2021-08-11 21:48:33 +00:00
|
|
|
/** Each item in the array maps to a newly-created `<style>` element, where object properties map to attributes. */
|
2021-03-28 20:14:04 +00:00
|
|
|
style: [],
|
2021-08-11 21:48:33 +00:00
|
|
|
/** Each item in the array maps to a newly-created `<script>` element, where object properties map to attributes. */
|
2021-03-28 20:14:04 +00:00
|
|
|
script: []
|
|
|
|
},
|
|
|
|
|
2021-04-15 18:49:29 +00:00
|
|
|
/**
|
|
|
|
* Configuration for the Nuxt `fetch()` hook.
|
2021-08-11 21:48:33 +00:00
|
|
|
* @version 2
|
2021-04-15 18:49:29 +00:00
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
fetch: {
|
2021-04-15 18:49:29 +00:00
|
|
|
/** Whether to enable `fetch()` on the server. */
|
2021-03-28 20:14:04 +00:00
|
|
|
server: true,
|
2021-04-15 18:49:29 +00:00
|
|
|
/** Whether to enable `fetch()` on the client. */
|
2021-03-28 20:14:04 +00:00
|
|
|
client: true
|
|
|
|
},
|
|
|
|
|
2021-04-15 18:49:29 +00:00
|
|
|
/**
|
|
|
|
* An array of nuxt app plugins.
|
|
|
|
*
|
|
|
|
* Each plugin can be a string (which can be an absolute or relative path to a file).
|
|
|
|
* If it ends with `.client` or `.server` then it will be automatically loaded only
|
|
|
|
* in the appropriate context.
|
|
|
|
*
|
|
|
|
* It can also be an object with `src` and `mode` keys.
|
|
|
|
*
|
|
|
|
* @example
|
|
|
|
* ```js
|
|
|
|
* plugins: [
|
|
|
|
* '~/plugins/foo.client.js', // only in client side
|
|
|
|
* '~/plugins/bar.server.js', // only in server side
|
|
|
|
* '~/plugins/baz.js', // both client & server
|
|
|
|
* { src: '~/plugins/both-sides.js' },
|
|
|
|
* { src: '~/plugins/client-only.js', mode: 'client' }, // only on client side
|
|
|
|
* { src: '~/plugins/server-only.js', mode: 'server' } // only on server side
|
|
|
|
* ]
|
|
|
|
* ```
|
2021-08-11 21:48:33 +00:00
|
|
|
* @version 2
|
2021-04-15 18:49:29 +00:00
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
plugins: [],
|
|
|
|
|
2021-04-15 18:49:29 +00:00
|
|
|
/**
|
|
|
|
* You may want to extend plugins or change their order. For this, you can pass
|
|
|
|
* a function using `extendPlugins`. It accepts an array of plugin objects and
|
|
|
|
* should return an array of plugin objects.
|
2021-08-11 21:48:33 +00:00
|
|
|
* @version 2
|
2021-04-15 18:49:29 +00:00
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
extendPlugins: null,
|
|
|
|
|
2021-04-15 18:49:29 +00:00
|
|
|
/**
|
|
|
|
* You can define the CSS files/modules/libraries you want to set globally
|
|
|
|
* (included in every page).
|
|
|
|
*
|
|
|
|
* Nuxt will automatically guess the file type by its extension and use the
|
|
|
|
* appropriate pre-processor. You will still need to install the required
|
|
|
|
* loader if you need to use them.
|
|
|
|
*
|
|
|
|
* @example
|
|
|
|
* ```js
|
|
|
|
* css: [
|
|
|
|
* // Load a Node.js module directly (here it's a Sass file)
|
|
|
|
* 'bulma',
|
|
|
|
* // CSS file in the project
|
|
|
|
* '@/assets/css/main.css',
|
|
|
|
* // SCSS file in the project
|
|
|
|
* '@/assets/css/main.scss'
|
|
|
|
* ]
|
|
|
|
* ```
|
2021-08-11 21:48:33 +00:00
|
|
|
* @version 2
|
2021-04-15 18:49:29 +00:00
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
css: [],
|
|
|
|
|
2021-04-15 18:49:29 +00:00
|
|
|
/**
|
|
|
|
* An object where each key name maps to a path to a layout .vue file.
|
|
|
|
*
|
|
|
|
* Normally there is no need to configure this directly.
|
2021-08-11 21:48:33 +00:00
|
|
|
* @version 2
|
2021-04-15 18:49:29 +00:00
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
layouts: {},
|
|
|
|
|
2021-04-15 18:49:29 +00:00
|
|
|
/**
|
|
|
|
* Set a custom error page layout.
|
|
|
|
*
|
|
|
|
* Normally there is no need to configure this directly.
|
2021-08-11 21:48:33 +00:00
|
|
|
* @version 2
|
2021-04-15 18:49:29 +00:00
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
ErrorPage: null,
|
|
|
|
|
2021-04-15 18:49:29 +00:00
|
|
|
/**
|
|
|
|
* Configure the Nuxt loading progress bar component that's shown between
|
|
|
|
* routes. Set to `false` to disable. You can also customize it or create
|
|
|
|
* your own component.
|
2021-08-11 21:48:33 +00:00
|
|
|
* @version 2
|
2021-04-15 18:49:29 +00:00
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
loading: {
|
2021-04-15 18:49:29 +00:00
|
|
|
/** CSS color of the progress bar */
|
2021-03-28 20:14:04 +00:00
|
|
|
color: 'black',
|
2021-04-15 18:49:29 +00:00
|
|
|
/**
|
|
|
|
* CSS color of the progress bar when an error appended while rendering
|
|
|
|
* the route (if data or fetch sent back an error for example).
|
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
failedColor: 'red',
|
2021-04-15 18:49:29 +00:00
|
|
|
/** Height of the progress bar (used in the style property of the progress bar). */
|
2021-03-28 20:14:04 +00:00
|
|
|
height: '2px',
|
2021-04-15 18:49:29 +00:00
|
|
|
/**
|
|
|
|
* In ms, wait for the specified time before displaying the progress bar.
|
|
|
|
* Useful for preventing the bar from flashing.
|
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
throttle: 200,
|
2021-04-15 18:49:29 +00:00
|
|
|
/**
|
|
|
|
* In ms, the maximum duration of the progress bar, Nuxt assumes that the
|
|
|
|
* route will be rendered before 5 seconds.
|
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
duration: 5000,
|
2021-04-15 18:49:29 +00:00
|
|
|
/** Keep animating progress bar when loading takes longer than duration. */
|
2021-03-28 20:14:04 +00:00
|
|
|
continuous: false,
|
2021-04-15 18:49:29 +00:00
|
|
|
/** Set the direction of the progress bar from right to left. */
|
2021-03-28 20:14:04 +00:00
|
|
|
rtl: false,
|
2021-04-15 18:49:29 +00:00
|
|
|
/** Set to false to remove default progress bar styles (and add your own). */
|
2021-03-28 20:14:04 +00:00
|
|
|
css: true
|
|
|
|
},
|
|
|
|
|
2021-04-15 18:49:29 +00:00
|
|
|
/**
|
|
|
|
* Show a loading spinner while the page is loading (only when `ssr: false`).
|
|
|
|
*
|
|
|
|
* Set to `false` to disable. Alternatively, you can pass a string name or an object for more
|
|
|
|
* configuration. The name can refer to an indicator from [SpinKit](https://tobiasahlin.com/spinkit/)
|
|
|
|
* or a path to an HTML template of the indicator source code (in this case, all the
|
|
|
|
* other options will be passed to the template.)
|
2021-08-11 21:48:33 +00:00
|
|
|
* @version 2
|
2021-04-15 18:49:29 +00:00
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
loadingIndicator: {
|
|
|
|
$resolve: (val, get) => {
|
|
|
|
if (typeof val === 'string') {
|
|
|
|
val = { name: val }
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
name: 'default',
|
|
|
|
color: get('loading.color') || '#D3D3D3',
|
|
|
|
color2: '#F5F5F5',
|
|
|
|
background: (get('manifest') && get('manifest.theme_color')) || 'white',
|
|
|
|
dev: get('dev'),
|
|
|
|
loading: get('messages.loading'),
|
|
|
|
...val
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2021-04-15 18:49:29 +00:00
|
|
|
/**
|
|
|
|
* Used to set the default properties of the page transitions.
|
|
|
|
*
|
|
|
|
* You can either pass a string (the transition name) or an object with properties to bind
|
|
|
|
* to the `<Transition>` component that will wrap your pages.
|
|
|
|
*
|
|
|
|
* @see [vue@2 documentation](https://vuejs.org/v2/guide/transitions.html)
|
|
|
|
* @see [vue@3 documentation](https://v3.vuejs.org/guide/transitions-enterleave.html)
|
2021-08-11 21:48:33 +00:00
|
|
|
* @version 2
|
2021-04-15 18:49:29 +00:00
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
pageTransition: {
|
|
|
|
$resolve: val => typeof val === 'string' ? { name: val } : val,
|
|
|
|
name: 'page',
|
|
|
|
mode: 'out-in',
|
|
|
|
appear: { $resolve: (val, get) => (get('render.ssr') === false) ? true : Boolean(val) },
|
|
|
|
appearClass: 'appear',
|
|
|
|
appearActiveClass: 'appear-active',
|
|
|
|
appearToClass: 'appear-to'
|
|
|
|
},
|
|
|
|
|
2021-04-15 18:49:29 +00:00
|
|
|
/**
|
|
|
|
* Used to set the default properties of the layout transitions.
|
|
|
|
*
|
|
|
|
* You can either pass a string (the transition name) or an object with properties to bind
|
|
|
|
* to the `<Transition>` component that will wrap your layouts.
|
|
|
|
*
|
|
|
|
* @see [vue@2 documentation](https://vuejs.org/v2/guide/transitions.html)
|
|
|
|
* @see [vue@3 documentation](https://v3.vuejs.org/guide/transitions-enterleave.html)
|
2021-08-11 21:48:33 +00:00
|
|
|
* @version 2
|
2021-04-15 18:49:29 +00:00
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
layoutTransition: {
|
|
|
|
$resolve: val => typeof val === 'string' ? { name: val } : val,
|
|
|
|
name: 'layout',
|
|
|
|
mode: 'out-in'
|
|
|
|
},
|
|
|
|
|
2021-04-15 18:49:29 +00:00
|
|
|
/**
|
|
|
|
* You can disable specific Nuxt features that you do not want.
|
2021-08-11 21:48:33 +00:00
|
|
|
* @version 2
|
2021-04-15 18:49:29 +00:00
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
features: {
|
2021-04-15 18:49:29 +00:00
|
|
|
/** Set to false to disable Nuxt vuex integration */
|
2021-03-28 20:14:04 +00:00
|
|
|
store: true,
|
2021-04-15 18:49:29 +00:00
|
|
|
/** Set to false to disable layouts */
|
2021-03-28 20:14:04 +00:00
|
|
|
layouts: true,
|
2021-04-15 18:49:29 +00:00
|
|
|
/** Set to false to disable Nuxt integration with `vue-meta` and the `head` property */
|
2021-03-28 20:14:04 +00:00
|
|
|
meta: true,
|
2021-04-15 18:49:29 +00:00
|
|
|
/** Set to false to disable middleware */
|
2021-03-28 20:14:04 +00:00
|
|
|
middleware: true,
|
2021-04-15 18:49:29 +00:00
|
|
|
/** Set to false to disable transitions */
|
2021-03-28 20:14:04 +00:00
|
|
|
transitions: true,
|
2021-04-15 18:49:29 +00:00
|
|
|
/** Set to false to disable support for deprecated features and aliases */
|
2021-03-28 20:14:04 +00:00
|
|
|
deprecations: true,
|
2021-04-15 18:49:29 +00:00
|
|
|
/** Set to false to disable the Nuxt `validate()` hook */
|
2021-03-28 20:14:04 +00:00
|
|
|
validate: true,
|
2021-04-15 18:49:29 +00:00
|
|
|
/** Set to false to disable the Nuxt `asyncData()` hook */
|
2021-03-28 20:14:04 +00:00
|
|
|
asyncData: true,
|
2021-04-15 18:49:29 +00:00
|
|
|
/** Set to false to disable the Nuxt `fetch()` hook */
|
2021-03-28 20:14:04 +00:00
|
|
|
fetch: true,
|
2021-04-15 18:49:29 +00:00
|
|
|
/** Set to false to disable `$nuxt.isOnline` */
|
2021-03-28 20:14:04 +00:00
|
|
|
clientOnline: true,
|
2021-04-15 18:49:29 +00:00
|
|
|
/** Set to false to disable prefetching behavior in `<NuxtLink>` */
|
2021-03-28 20:14:04 +00:00
|
|
|
clientPrefetch: true,
|
2021-04-15 18:49:29 +00:00
|
|
|
/** Set to false to disable extra component aliases like `<NLink>` and `<NChild>` */
|
2021-03-28 20:14:04 +00:00
|
|
|
componentAliases: true,
|
2021-04-15 18:49:29 +00:00
|
|
|
/** Set to false to disable the `<ClientOnly>` component (see [docs](https://github.com/egoist/vue-client-only)) */
|
2021-03-28 20:14:04 +00:00
|
|
|
componentClientOnly: true
|
|
|
|
}
|
|
|
|
}
|