You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would you accept a PR for a @nuxtjs/plugin-helper package which will at least contain debug/info functions? At the moment most logging by the plugins are done by calling console.log, but it would be nice if we use the same debug package as nuxtjs uses so all output during build is nicely formatted.
My idea would be to export functions that always add a 'plugin:' text to the logging. And maybe we choose a different colour then nuxt's blue? This way we have an uniform and recognizable way of logging.
module.exports.meta=require('./package.json')constdebug=require('@nuxtjs/plugin-utils').log(module.exports.meta.name)consterror=require('@nuxtjs/plugin-utils').error(module.exports.meta.name)log('information about what the plugin is doing during build')// printed in purpleerror('oops, something went wrong')// printed in red
I am using currently something similar for rfg-icon, but think we could benefit if we centralize the logging :)
This question is available on Nuxt.js community (#c44)
The text was updated successfully, but these errors were encountered:
Hi. That's a nice idea indeed i was also thinking of a helper package for plugins! I suggest some improvements to basic idea:
Having a more general name like plugin-utils
Create debug instances out of arrow functions once, for performance.
Using some template condition to remove dependency of Debug package from production builds. This is important as can add unwanted package size. (We can create a noop handler like () => () => null to remove debug)
I updated both example codes, would something like that be ok? I used a simple if (process.env.NODE_ENV === 'production') { so code is removed through tree shaking. Not sure how you could get template conditions to work here while keeping a package that works both in prod as in dev.
Would you accept a PR for a
@nuxtjs/plugin-helper
package which will at least contain debug/info functions? At the moment most logging by the plugins are done by callingconsole.log
, but it would be nice if we use the samedebug
package asnuxtjs
uses so all output during build is nicely formatted.My idea would be to export functions that always add a 'plugin:' text to the logging. And maybe we choose a different colour then nuxt's blue? This way we have an uniform and recognizable way of logging.
and usage would be:
I am using currently something similar for
rfg-icon
, but think we could benefit if we centralize the logging :)The text was updated successfully, but these errors were encountered: