mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-31 15:50:32 +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({
|
export default defineNuxtModule({
|
||||||
meta: {
|
meta: {
|
||||||
name: 'router'
|
name: 'pages'
|
||||||
},
|
},
|
||||||
setup (_options, nuxt) {
|
setup (_options, nuxt) {
|
||||||
const pagesDirs = nuxt.options._layers.map(
|
const pagesDirs = nuxt.options._layers.map(
|
||||||
layer => resolve(layer.config.srcDir, layer.config.dir?.pages || 'pages')
|
layer => resolve(layer.config.srcDir, layer.config.dir?.pages || 'pages')
|
||||||
)
|
)
|
||||||
|
|
||||||
// Disable module (and use universal router) if pages dir do not exists
|
// Disable module (and use universal router) if pages dir do not exists or user has disabled it
|
||||||
if (!pagesDirs.some(dir => existsSync(dir))) {
|
if (nuxt.options.pages === false || (nuxt.options.pages !== true && !pagesDirs.some(dir => existsSync(dir)))) {
|
||||||
addPlugin(resolve(distDir, 'app/plugins/router'))
|
addPlugin(resolve(distDir, 'app/plugins/router'))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -35,4 +35,13 @@ export default {
|
|||||||
global: false,
|
global: false,
|
||||||
dirs: []
|
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