diff --git a/packages/vue-app/template/client.js b/packages/vue-app/template/client.js index 91f20e6725..cddfe76153 100644 --- a/packages/vue-app/template/client.js +++ b/packages/vue-app/template/client.js @@ -20,7 +20,9 @@ import { createApp, NuxtError } from './index.js' import NuxtLink from './components/nuxt-link.<%= router.prefetchLinks ? "client" : "server" %>.js' // should be included after ./index.js <% if (isDev) { %>import consola from 'consola'<% } %> -<% if (isDev) { %>consola.wrapConsole()<% } %> +<% if (isDev) { %>consola.wrapConsole() +console.log = console.__log +<% } %> // Component: Vue.component(NuxtLink.name, NuxtLink) diff --git a/packages/vue-app/template/server.js b/packages/vue-app/template/server.js index 2e70cd2b84..9edda3de3d 100644 --- a/packages/vue-app/template/server.js +++ b/packages/vue-app/template/server.js @@ -1,5 +1,4 @@ import { stringify } from 'querystring' -import consola from 'consola' import Vue from 'vue' <% if (fetch.server) { %>import fetch from 'node-fetch'<% } %> import middleware from './middleware.js' @@ -98,7 +97,7 @@ export default async (ssrContext) => { try { await store.dispatch('nuxtServerInit', app.context) } catch (err) { - consola.debug('Error occurred when calling nuxtServerInit: ', err.message) + console.debug('Error occurred when calling nuxtServerInit: ', err.message) throw err } } @@ -219,7 +218,7 @@ export default async (ssrContext) => { return Promise.all(promises) })) - <% if (debug) { %>if (asyncDatas.length) consola.debug('Data fetching ' + ssrContext.url + ': ' + (Date.now() - s) + 'ms')<% } %> + <% if (debug) { %>if (process.env.DEBUG && asyncDatas.length)console.debug('Data fetching ' + ssrContext.url + ': ' + (Date.now() - s) + 'ms')<% } %> // datas are the first row of each ssrContext.nuxt.data = asyncDatas.map(r => r[0] || {}) diff --git a/packages/vue-app/template/store.js b/packages/vue-app/template/store.js index 46ecd29eac..1d084db70d 100644 --- a/packages/vue-app/template/store.js +++ b/packages/vue-app/template/store.js @@ -3,7 +3,6 @@ import Vuex from 'vuex' Vue.use(Vuex) -const log = console // on server-side, consola will catch all console.log const VUEX_PROPERTIES = ['state', 'getters', 'actions', 'mutations'] let store = {} @@ -16,7 +15,7 @@ void (function updateModules() { // If store is an exported method = classic mode (deprecated) <% if (isDev) { %> if (typeof store === 'function') { - return log.warn('Classic mode for store/ is deprecated and will be removed in Nuxt 3.') + return console.warn('Classic mode for store/ is deprecated and will be removed in Nuxt 3.') }<% } %> // Enforce store modules @@ -104,7 +103,7 @@ function normalizeRoot(moduleData, filePath) { function normalizeState(moduleData, filePath) { if (typeof moduleData !== 'function') { - log.warn(`${filePath} should export a method that returns an object`) + console.warn(`${filePath} should export a method that returns an object`) const state = Object.assign({}, moduleData) return () => state } @@ -113,7 +112,7 @@ function normalizeState(moduleData, filePath) { function normalizeModule(moduleData, filePath) { if (moduleData.state && typeof moduleData.state !== 'function') { - log.warn(`'state' should be a method that returns an object in ${filePath}`) + console.warn(`'state' should be a method that returns an object in ${filePath}`) const state = Object.assign({}, moduleData.state) // Avoid TypeError: setting a property that has only a getter when overwriting top level keys moduleData = Object.assign({}, moduleData, { state: () => state })