Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use full build of consola for development time #1991

Closed
pi0 opened this issue Dec 8, 2023 · 4 comments · Fixed by #2110
Closed

use full build of consola for development time #1991

pi0 opened this issue Dec 8, 2023 · 4 comments · Fixed by #2110
Labels

Comments

@pi0
Copy link
Member

pi0 commented Dec 8, 2023

Context: #1761

We automatically use lighter build of consola for production but for development, we can keep using fancy logger.

@XStarlink
Copy link

@cany748 Thanks a lot for the fix!

I'm trying to import consola to log requests received by nitro but I still have an unformatted version of consola, what's the right way to import it?

For now I'm doing it this way:

import { consola } from 'consola'

consola.box({
  title: `Request at ${time}`,
  message: `[${event.method}] ${event.path}`
})

Thanks in advance for your advice

@cany748
Copy link
Contributor

cany748 commented Feb 29, 2024

@cany748 Thanks a lot for the fix!

I'm trying to import consola to log requests received by nitro but I still have an unformatted version of consola, what's the right way to import it?

For now I'm doing it this way:

import { consola } from 'consola'

consola.box({
  title: `Request at ${time}`,
  message: `[${event.method}] ${event.path}`
})

Thanks in advance for your advice

Do you need the full version of consola in production mode? Try this:

// nitro.config.ts
export default defineNitroConfig({
  imports: { imports: [{ name: "consola", from: "consola" }] },
  unenv: { alias: { consola: "consola" } },
});

And use the auto-imported consola.

@XStarlink
Copy link

@cany748 Thanks a lot for the fix!
I'm trying to import consola to log requests received by nitro but I still have an unformatted version of consola, what's the right way to import it?
For now I'm doing it this way:

import { consola } from 'consola'

consola.box({
  title: `Request at ${time}`,
  message: `[${event.method}] ${event.path}`
})

Thanks in advance for your advice

Do you need the full version of consola in production mode? Try this:

// nitro.config.ts
export default defineNitroConfig({
  imports: { imports: [{ name: "consola", from: "consola" }] },
  unenv: { alias: { consola: "consola" } },
});

And use the auto-imported consola.

@cany748 Thank you very much, it works!
(I had to put this config in the nitro key of nuxt.config.ts because nuxt warned me that nitro.config.ts cannot be used with nuxt)

I only need consola in dev, will this method be only effetive in dev or also in production (after build)?

I have a second question, why do we have to add these options to access consola when you've made the fix above which seemed to no longer mock the full build of consola in dev?

@cany748
Copy link
Contributor

cany748 commented Mar 6, 2024

I only need consola in dev, will this method be only effetive in dev or also in production (after build)?

The full version of consola will be available in Production mode

I have a second question, why do we have to add these options to access consola when you've made the fix above which seemed to no longer mock the full build of consola in dev?

try updating the dependencies

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants