import { resolve, join } from 'pathe' import { existsSync, readdirSync } from 'fs' import defu from 'defu' export default { /** * Vue.js config * @version 2 * @version 3 */ vue: { /** * Properties that will be set directly on `Vue.config` for vue@2. * * @see [vue@2 Documentation](https://v2.vuejs.org/v2/api/#Global-Config) * @type {import('vue/types/vue').VueConfiguration} * @version 2 */ config: { silent: { $resolve: (val, get) => val ?? !get('dev') }, performance: { $resolve: (val, get) => val ?? get('dev') }, }, /** * Options for the Vue compiler that will be passed at build time * @see [documentation](https://vuejs.org/api/application.html#app-config-compileroptions) * @type {import('@vue/compiler-core').CompilerOptions} * @version 3 */ compilerOptions: {} }, /** * Nuxt App configuration. * @version 2 * @version 3 */ app: { /** * The base path of your Nuxt application. * * This can be set at runtime by setting the NUXT_APP_BASE_URL environment variable. * @example * ```bash * NUXT_APP_BASE_URL=/prefix/ node .output/server/index.mjs * ``` */ baseURL: process.env.NUXT_APP_BASE_URL || '/', /** The folder name for the built site assets, relative to `baseURL` (or `cdnURL` if set). This is set at build time and should not be customized at runtime. */ buildAssetsDir: process.env.NUXT_APP_BUILD_ASSETS_DIR || '/_nuxt/', /** * The folder name for the built site assets, relative to `baseURL` (or `cdnURL` if set). * @deprecated - use `buildAssetsDir` instead * @version 2 */ assetsPath: { $resolve: (val, get) => val ?? get('buildAssetsDir') }, /** * An absolute URL to serve the public folder from (production-only). * * This can be set to a different value at runtime by setting the CDN_URL environment variable. * @example * ```bash * CDN_URL=https://mycdn.org/ node .output/server/index.mjs * ``` */ cdnURL: { $resolve: (val, get) => get('dev') ? '' : (process.env.NUXT_APP_CDN_URL ?? val) || '' }, /** * Set default configuration for `` on every page. * * @example * ```js * app: { * head: { * meta: [ * // * { name: 'viewport', content: 'width=device-width, initial-scale=1' } * ], * script: [ * // * { src: 'https://awesome-lib.js' } * ], * link: [ * // * { rel: 'stylesheet', href: 'https://awesome-lib.css' } * ], * // please note that this is an area that is likely to change * style: [ * // * { children: ':root { color: red }', type: 'text/css' } * ] * } * } * ``` * @type {typeof import('../src/types/meta').MetaObject} * @version 3 */ head: { $resolve: (val, get) => { return defu(val, get('meta'), { meta: [], link: [], style: [], script: [] }) } }, }, /** * 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). * @type {import('vue-meta').VueMetaOptions} * @version 2 */ vueMeta: null, /** * Set default configuration for `` on every page. * * @see [documentation](https://vue-meta.nuxtjs.org/api/#metainfo-properties) for specifics. * @type {import('vue-meta').MetaInfo} * @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 `