Skip to content

Commit

Permalink
feat(nuxt3): allow manually enabling/disabling the ad-hoc pages module (
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe authored Apr 13, 2022
1 parent a89d2f9 commit f4fb916
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/nuxt3/src/pages/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
9 changes: 9 additions & 0 deletions packages/schema/src/config/_adhoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit f4fb916

Please sign in to comment.