This commit is contained in:
Sebastien Chopin 2017-08-17 15:13:56 +02:00
parent 646ad35815
commit e3eb83d669

View File

@ -89,7 +89,7 @@ export default class Builder extends Tapable {
}) })
} }
forGenerate() { forGenerate () {
this.isStatic = true this.isStatic = true
} }
@ -195,10 +195,10 @@ export default class Builder extends Tapable {
// -- Layouts -- // -- Layouts --
if (fs.existsSync(resolve(this.options.srcDir, 'layouts'))) { if (fs.existsSync(resolve(this.options.srcDir, 'layouts'))) {
const layoutsFiles = await glob('layouts/*.{vue,js}', { cwd: this.options.srcDir }) const layoutsFiles = await glob('layouts/*.vue', { cwd: this.options.srcDir })
let hasErrorLayout = false let hasErrorLayout = false
layoutsFiles.forEach((file) => { layoutsFiles.forEach((file) => {
let name = file.split('/').slice(-1)[0].replace(/\.(js|vue)$/, '') let name = file.split('/').slice(-1)[0].replace(/\.vue$/, '')
if (name === 'error') { if (name === 'error') {
hasErrorLayout = true hasErrorLayout = true
return return
@ -206,7 +206,7 @@ export default class Builder extends Tapable {
templateVars.layouts[name] = this.relativeToBuild(this.options.srcDir, file) templateVars.layouts[name] = this.relativeToBuild(this.options.srcDir, file)
}) })
if (!templateVars.components.ErrorPage && hasErrorLayout) { if (!templateVars.components.ErrorPage && hasErrorLayout) {
templateVars.components.ErrorPage = this.relativeToBuild(this.options.srcDir, 'layouts/error') templateVars.components.ErrorPage = this.relativeToBuild(this.options.srcDir, 'layouts/error.vue')
} }
} }
// If no default layout, create its folder and add the default folder // If no default layout, create its folder and add the default folder
@ -221,7 +221,7 @@ export default class Builder extends Tapable {
// If user defined a custom method to create routes // If user defined a custom method to create routes
if (this._nuxtPages) { if (this._nuxtPages) {
// Use nuxt.js createRoutes bases on pages/ // Use nuxt.js createRoutes bases on pages/
const files = await glob('pages/**/*.{vue,js}', { cwd: this.options.srcDir }) const files = await glob('pages/**/*.vue', { cwd: this.options.srcDir })
templateVars.router.routes = createRoutes(files, this.options.srcDir) templateVars.router.routes = createRoutes(files, this.options.srcDir)
} else { } else {
templateVars.router.routes = this.options.build.createRoutes(this.options.srcDir) templateVars.router.routes = this.options.build.createRoutes(this.options.srcDir)
@ -469,13 +469,13 @@ export default class Builder extends Tapable {
r(this.options.srcDir, 'layouts'), r(this.options.srcDir, 'layouts'),
r(this.options.srcDir, 'store'), r(this.options.srcDir, 'store'),
r(this.options.srcDir, 'middleware'), r(this.options.srcDir, 'middleware'),
r(this.options.srcDir, 'layouts/*.{vue,js}'), r(this.options.srcDir, 'layouts/*.vue'),
r(this.options.srcDir, 'layouts/**/*.{vue,js}') r(this.options.srcDir, 'layouts/**/*.vue')
] ]
if (this._nuxtPages) { if (this._nuxtPages) {
patterns.push(r(this.options.srcDir, 'pages')) patterns.push(r(this.options.srcDir, 'pages'))
patterns.push(r(this.options.srcDir, 'pages/*.{vue,js}')) patterns.push(r(this.options.srcDir, 'pages/*.vue'))
patterns.push(r(this.options.srcDir, 'pages/**/*.{vue,js}')) patterns.push(r(this.options.srcDir, 'pages/**/*.vue'))
} }
const options = Object.assign({}, this.options.watchers.chokidar, { const options = Object.assign({}, this.options.watchers.chokidar, {
ignoreInitial: true ignoreInitial: true