From f4fb9160c612bf9400861be6d4f76d762ca41f73 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Wed, 13 Apr 2022 18:18:51 +0100 Subject: [PATCH] feat(nuxt3): allow manually enabling/disabling the ad-hoc pages module (#4327) --- packages/nuxt3/src/pages/module.ts | 6 +++--- packages/schema/src/config/_adhoc.ts | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/nuxt3/src/pages/module.ts b/packages/nuxt3/src/pages/module.ts index ab7ef47d73..950eab2063 100644 --- a/packages/nuxt3/src/pages/module.ts +++ b/packages/nuxt3/src/pages/module.ts @@ -9,15 +9,15 @@ import { TransformMacroPlugin, TransformMacroPluginOptions } from './macros' export default defineNuxtModule({ meta: { - name: 'router' + name: 'pages' }, setup (_options, nuxt) { const pagesDirs = nuxt.options._layers.map( layer => resolve(layer.config.srcDir, layer.config.dir?.pages || 'pages') ) - // Disable module (and use universal router) if pages dir do not exists - if (!pagesDirs.some(dir => existsSync(dir))) { + // Disable module (and use universal router) if pages dir do not exists or user has disabled it + if (nuxt.options.pages === false || (nuxt.options.pages !== true && !pagesDirs.some(dir => existsSync(dir)))) { addPlugin(resolve(distDir, 'app/plugins/router')) return } diff --git a/packages/schema/src/config/_adhoc.ts b/packages/schema/src/config/_adhoc.ts index f58fee8b65..130e77a04b 100644 --- a/packages/schema/src/config/_adhoc.ts +++ b/packages/schema/src/config/_adhoc.ts @@ -35,4 +35,13 @@ export default { global: false, dirs: [] }, + + /** + * Whether to use the vue-router integration in Nuxt 3. If you do not provide a value it will be + * enabled if you have a `pages/` directory in your source folder. + * + * @type {boolean} + * @version 3 + */ + pages: undefined }