mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-19 01:45:53 +00:00
feat(nuxt3): allow manually enabling/disabling the ad-hoc pages module (#4327)
This commit is contained in:
parent
a89d2f9c1a
commit
f4fb9160c6
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user