import { resolve, join } from 'upath' import { existsSync, readdirSync } from 'fs' import defu from 'defu' import { isRelative, joinURL, hasProtocol } from 'ufo' export default { /** Vue.js config */ vue: { /** * 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) */ config: { silent: { $resolve: (val, get) => val ?? !get('dev') }, performance: { $resolve: (val, get) => val ?? get('dev') } } }, /** * Nuxt App configuration. */ 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 }) } }, /** * The path to a templated HTML file for rendering Nuxt responses. * Uses `/app.html` if it exists or the Nuxt default template if not. * * @example * ```html * * * * {{ HEAD }} * * * {{ APP }} * * * ``` */ 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') } }, /** * Enable or disable vuex store. * By default is enbled if there is store / directory */ 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] !== '.') }, /** * Options to pass directly to `vue-meta`. * * @see [documentation](https://vue-meta.nuxtjs.org/api/#plugin-options). */ vueMeta: null, /** * Set default configuration for `` on every page. * * @see [documentation](https://vue-meta.nuxtjs.org/api/#metainfo-properties) for specifics. */ head: { /** Each item in the array maps to a newly-created element, where object properties map to attributes. */ meta: [], /** Each item in the array maps to a newly-created element, where object properties map to attributes. */ link: [], /** Each item in the array maps to a newly-created