From 2ff304898dc6a148fa0d8825da0811b691f864d4 Mon Sep 17 00:00:00 2001 From: Alexandre Chopin Date: Wed, 17 May 2017 16:19:22 +0200 Subject: [PATCH] generate only index.html when router.mode = 'hash' --- lib/generate.js | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/lib/generate.js b/lib/generate.js index 2bcc6d2674..9128f12a19 100644 --- a/lib/generate.js +++ b/lib/generate.js @@ -69,24 +69,29 @@ export default async function () { } await copy(srcBuiltPath, distNuxtPath) debug('Static & build files copied') + if (this.options.router !== 'hash') { // Resolve config.generate.routes promises before generating the routes - try { - var generateRoutes = await promisifyRoute(this.options.generate.routes || []) - } catch (e) { - console.error('Could not resolve routes') // eslint-disable-line no-console - console.error(e) // eslint-disable-line no-console - process.exit(1) - throw e // eslint-disable-line no-unreachable + try { + var generateRoutes = await promisifyRoute(this.options.generate.routes || []) + } catch (e) { + console.error('Could not resolve routes') // eslint-disable-line no-console + console.error(e) // eslint-disable-line no-console + process.exit(1) + throw e // eslint-disable-line no-unreachable + } + /* + ** Generate html files from routes + */ + generateRoutes.forEach((route) => { + if (this.routes.indexOf(route) < 0) { + this.routes.push(route) + } + }) } /* - ** Generate html files from routes + ** Generate only index.html for router.mode = 'hash' */ - generateRoutes.forEach((route) => { - if (this.routes.indexOf(route) < 0) { - this.routes.push(route) - } - }) - let routes = this.routes + let routes = (this.options.router === 'hash') ? ['/'] : this.routes while (routes.length) { let n = 0 await Promise.all(routes.splice(0, 500).map(async (route) => {