diff --git a/lib/app/router.js b/lib/app/router.js index 2238ee8ef3..b49a436aa9 100644 --- a/lib/app/router.js +++ b/lib/app/router.js @@ -7,8 +7,9 @@ import Router from 'vue-router' route._name = '_' + hash(route.component) components.push({ _name: route._name, component: route.component, name: route.name, chunkName: route.chunkName }) res += tab + '{\n' - res += tab + '\tpath: ' + JSON.stringify(route.path) + ',\n' - res += tab + '\tcomponent: ' + (splitPages ? route._name : `() => ${route._name}.default || ${route._name}`) + res += tab + '\tpath: ' + JSON.stringify(route.path) + res += (route.component) ? ',\n\t' + tab + 'component: ' + (splitPages ? route._name : `() => ${route._name}.default || ${route._name}`) : '' + res += (route.redirect) ? ',\n\t' + tab + 'redirect: ' + JSON.stringify(route.redirect) : '' res += (route.name) ? ',\n\t' + tab + 'name: ' + JSON.stringify(route.name) : '' res += (route.children) ? ',\n\t' + tab + 'children: [\n' + recursiveRoutes(routes[i].children, tab + '\t\t', components) + '\n\t' + tab + ']' : '' res += '\n' + tab + '}' + (i + 1 === routes.length ? '' : ',\n') @@ -18,6 +19,7 @@ import Router from 'vue-router' const _components = [] const _routes = recursiveRoutes(router.routes, '\t\t', _components) %><%= uniqBy(_components, '_name').map((route) => { + if (!route.component) return '' const path = relativeToBuild(route.component) const chunkName = wChunk(route.chunkName) const name = route._name diff --git a/lib/builder/webpack/client.config.js b/lib/builder/webpack/client.config.js index 4163a21e15..5c1e70922c 100644 --- a/lib/builder/webpack/client.config.js +++ b/lib/builder/webpack/client.config.js @@ -3,13 +3,14 @@ import webpack from 'webpack' // import VueSSRClientPlugin from 'vue-server-renderer/client-plugin' import VueSSRClientPlugin from './plugins/vue/client' import HTMLPlugin from 'html-webpack-plugin' -import FriendlyErrorsWebpackPlugin from 'friendly-errors-webpack-plugin' +import FriendlyErrorsWebpackPlugin from '@nuxtjs/friendly-errors-webpack-plugin' import StylishPlugin from 'webpack-stylish' import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer' import { resolve } from 'path' import Debug from 'debug' import base from './base.config.js' + const debug = Debug('nuxt:build') debug.color = 2 // Force green color diff --git a/package.json b/package.json index d400b3b149..e8d47669d2 100644 --- a/package.json +++ b/package.json @@ -58,6 +58,7 @@ "npm": ">=5.0.0" }, "dependencies": { + "@nuxtjs/friendly-errors-webpack-plugin": "^2.0.0", "@nuxtjs/youch": "^4.2.3", "ansi-html": "^0.0.7", "autoprefixer": "^8.1.0", @@ -77,7 +78,6 @@ "extract-text-webpack-plugin": "^4.0.0-beta.0", "file-loader": "^1.1.11", "fresh": "^0.5.2", - "friendly-errors-webpack-plugin": "^1.6.1", "fs-extra": "^5.0.0", "glob": "^7.1.2", "hash-sum": "^1.0.2", diff --git a/test/fixtures/with-config/nuxt.config.js b/test/fixtures/with-config/nuxt.config.js index 80f0920abb..a8c6314350 100644 --- a/test/fixtures/with-config/nuxt.config.js +++ b/test/fixtures/with-config/nuxt.config.js @@ -12,6 +12,10 @@ export default { name: 'about-bis', path: '/about-bis', component: '~/pages/about.vue' + }, + { + path: '/redirect/about-bis', + redirect: '/about-bis' } ] } diff --git a/test/with-config.test.js b/test/with-config.test.js index e1bbcb3ef0..4ace3bd8d2 100644 --- a/test/with-config.test.js +++ b/test/with-config.test.js @@ -171,6 +171,21 @@ test.serial('/test/about-bis (added with extendRoutes)', async t => { t.true(html.includes('

About page

')) }) +test.serial('/test/redirect/about-bis (redirect with extendRoutes)', async t => { + const logSpy = await interceptLog() + const window = await nuxt.renderAndGetWindow(url('/test/redirect/about-bis')) + t.true(logSpy.calledOnce) + t.is(logSpy.args[0][0], 'Test plugin!') + release() + + const windowHref = window.location.href + t.true(windowHref.includes('/test/about-bis')) + + const html = window.document.body.innerHTML + t.true(html.includes('

Custom layout

')) + t.true(html.includes('

About page

')) +}) + test('Check stats.json generated by build.analyze', t => { const stats = require(resolve( __dirname, diff --git a/yarn.lock b/yarn.lock index f73ee7e582..a5650761c1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -122,6 +122,15 @@ pretty-ms "^0.2.1" text-table "^0.2.0" +"@nuxtjs/friendly-errors-webpack-plugin@^2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@nuxtjs/friendly-errors-webpack-plugin/-/friendly-errors-webpack-plugin-2.0.0.tgz#70fb321c78362e2b4bce1d522ecdf7f87a4dacec" + dependencies: + chalk "^2.3.2" + error-stack-parser "^2.0.0" + string-width "^2.0.0" + strip-ansi "^4.0.0" + "@nuxtjs/youch@^4.2.3": version "4.2.3" resolved "https://registry.yarnpkg.com/@nuxtjs/youch/-/youch-4.2.3.tgz#36f8b22df5a0efaa81373109851e1d857aca6bed" @@ -3218,14 +3227,6 @@ fresh@0.5.2, fresh@^0.5.2: version "0.5.2" resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7" -friendly-errors-webpack-plugin@^1.6.1: - version "1.6.1" - resolved "https://registry.yarnpkg.com/friendly-errors-webpack-plugin/-/friendly-errors-webpack-plugin-1.6.1.tgz#e32781c4722f546a06a9b5d7a7cfa28520375d70" - dependencies: - chalk "^1.1.3" - error-stack-parser "^2.0.0" - string-length "^1.0.1" - from2@^2.1.0: version "2.3.0" resolved "https://registry.yarnpkg.com/from2/-/from2-2.3.0.tgz#8bfb5502bde4a4d36cfdeea007fcca21d7e382af" @@ -7051,12 +7052,6 @@ strict-uri-encode@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz#279b225df1d582b1f54e65addd4352e18faa0713" -string-length@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/string-length/-/string-length-1.0.1.tgz#56970fb1c38558e9e70b728bf3de269ac45adfac" - dependencies: - strip-ansi "^3.0.0" - string-width@^1.0.1, string-width@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3"