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) * @version 2 */ config: { silent: { $resolve: (val, get) => val ?? !get('dev') }, performance: { $resolve: (val, get) => val ?? get('dev') } } }, /** * Nuxt App configuration. * @version 2 */ 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 }} * * * ``` * @version 2 */ 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 it is enabled if there is a `store/` directory * @version 2 */ 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). * @version 2 */ vueMeta: null, /** * Set default configuration for `` on every page. * * @see [documentation](https://vue-meta.nuxtjs.org/api/#metainfo-properties) for specifics. * @version 2 */ 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 `