😲 An environment-aware Nuxt Configuration

Поділитися
Вставка
  • Опубліковано 4 жов 2024

КОМЕНТАРІ • 52

  • @TheAlexLichter
    @TheAlexLichter  7 місяців тому

    What will you use the env-aware config option for?

    • @orenmizr
      @orenmizr 6 місяців тому

      isn't using env files the standard ? won't it conflict ?

    • @TheAlexLichter
      @TheAlexLichter  6 місяців тому

      No, not at all! You can use both together. An env file will set certain options that you might want to check during runtime via runtimeConfig
      The env aware config will enable you to change your config fully based on the environment.
      Could you do the same via env? Probably, but it’d be less clean or obvious

  • @fedvvvv
    @fedvvvv 7 місяців тому +9

    Hey Alex! you what would be a great episode? Unit testing in Nuxt 3! I haven't started unit testing my components but I should. It would be great to watch a good video tutorial as I heard it was a nightmare to test Nuxt 3 apps....

    • @TheAlexLichter
      @TheAlexLichter  7 місяців тому +4

      100%
      As mentioned after the intro, this is definitely planned!

    • @alexcroox
      @alexcroox 6 місяців тому +1

      @@TheAlexLichteralso unit testing the API part of nuxt. There are no resources on this at all currently!

    • @fedvvvv
      @fedvvvv 6 місяців тому

      @@TheAlexLichter awesome. Looking forward to it!

  • @pryanik150
    @pryanik150 6 місяців тому +4

    Понастоящему полезный контент💪.
    Спасибо огромное

  • @virusblitz
    @virusblitz 7 місяців тому +1

    Had no idea it is that easy! Awesome video as always

  • @ivangorobec2803
    @ivangorobec2803 3 місяці тому

    Thanks Alex! Much appreciate your work man.

  • @valacshiro378
    @valacshiro378 3 місяці тому

    another video that just saved my day :D thank you ill use this to set diferent apis urls for dev and prod :D

    • @TheAlexLichter
      @TheAlexLichter  3 місяці тому

      That's a good case (but also could work via runtimeConfig 😊) You are welcome!

  • @juliancoles7789
    @juliancoles7789 6 місяців тому +1

    I really learn a lot from your videos. Any chance you could do a video clarifying what packages should go into dependencies or devDependencies? For example, I have seen nuxt entered in dependencies and also in devDependencies, which is right? How can we know which package should go where?

    • @TheAlexLichter
      @TheAlexLichter  6 місяців тому +1

      Very happy that my videos help you 🙌🏻
      Yes, this is on the list but can vary a lot based on what type of framework you use and if you build an app or library ☺️
      For a nuxt app, I would put all in deps except libs for testing, linting etc etc

  • @Vladimir-if1uk
    @Vladimir-if1uk 7 місяців тому +1

    Thanks for the video!

  • @nuxist-z2k
    @nuxist-z2k 6 місяців тому +1

    Hey Alex, I'd really like to see the implementation of websockets in Nuxt3.
    I know it is theoretically possible with unjs ecosystem's H3/CrossWS packages, but since I've been experimenting with those and wasn't able to establish a handshake with wss, I could really use your help with those.

    • @TheAlexLichter
      @TheAlexLichter  6 місяців тому +1

      Video is coming ;)

    • @TheAlexLichter
      @TheAlexLichter  6 місяців тому +1

      And here it is - ua-cam.com/video/OfY7JcrqkPg/v-deo.html

    • @nuxist-z2k
      @nuxist-z2k 6 місяців тому

      ​@@TheAlexLichter Thank you so much for this one! At first I was like 'NO WAY' but it turned out you actually found spare time and put effort into making a video about the EXACT thing I was interested in 🙂.
      I am honored and humbled by this gesture of yours!
      Thank you for your everyday work and dedication ❤❤❤
      Hats off to you Sir Alex of Nuxt!

  • @muhammadrizkiwahyudi3334
    @muhammadrizkiwahyudi3334 7 місяців тому +1

    awesome, thanks for the video

  • @TdmitriyV
    @TdmitriyV 6 місяців тому +1

    nice video, really usefull. Thanks

  • @svenvanreenen
    @svenvanreenen 7 місяців тому +1

    wow this is a great one!

  • @CJohnD
    @CJohnD 2 місяці тому

    Great video!
    What if i want to have multiple versions of a website. For example I have a website but it needs to run in multiple country's with specific configs and runtime variables.
    Do i just make multiple nuxt.config files?
    How do i handle that?

  • @izzy7541
    @izzy7541 6 місяців тому +1

    How do I use custom environments?
    If I set $env: {$preview:{...} }, I still run in production

    • @TheAlexLichter
      @TheAlexLichter  6 місяців тому

      Follow along github.com/nuxt/cli/issues/357 ☺️

    • @Andrew-tl9gk
      @Andrew-tl9gk 2 місяці тому

      I am facing the same problem ... Cant set the NODE_ENV to anything because it will always fall back to production

  • @oscarrafaelcampos
    @oscarrafaelcampos 7 місяців тому +1

    Thanks!!

  • @SellOnResearch
    @SellOnResearch Місяць тому

    Gents is there anyway to define production API baseURL and development base_URL using this settings ?

    • @TheAlexLichter
      @TheAlexLichter  Місяць тому

      For example through the runtime config, absolutely!

  • @kobekobz
    @kobekobz 6 місяців тому

    I really like your videos about nuxt 3, im planning to migrate from nuxt 2 to nuxt 3 but im having a problem on implementing simple jwt auth on nuxt 3

    • @TheAlexLichter
      @TheAlexLichter  6 місяців тому

      Take a look at github.com/Atinux/nuxt-auth-utils 😊

  • @youhan96
    @youhan96 6 місяців тому +1

    How it fits there if I have a node_env named "preview". Do I do $preview:{...}

    • @TheAlexLichter
      @TheAlexLichter  6 місяців тому +1

      It is:
      $env: { $preview: {...} }

    • @Andrew-tl9gk
      @Andrew-tl9gk 2 місяці тому

      This is what I want to do but I cant set NODE_ENV because Nuxt will always change it back to "production" and show the warning as shown in the video... How to set NODE_ENV ???

  • @blackwhitelion10
    @blackwhitelion10 2 місяці тому

    Does it work during runtime? Means, can I change the config after build, will it take effect?

    • @TheAlexLichter
      @TheAlexLichter  2 місяці тому

      That’s the whole idea, yes!

    • @blackwhitelion10
      @blackwhitelion10 2 місяці тому

      @@TheAlexLichter Correct me if I am wrong. I thought the nuxt.config.ts will only be executed during build time. Let said, during build time the production.title is configured as 'Build Title'. During runtime, I would like to change the title name to 'Runtime Title'. I would like to do this without using environment variable. I tried your method, it does not seems work. The config file is not being read during runtime.

    • @TheAlexLichter
      @TheAlexLichter  Місяць тому

      Ah, sorry. My bad! No, you are correct. RuntimeConfig and env variables would be the only way to do so.
      The env-aware config should mainly help with "different types of builds", dev, and a testing environment.

  • @nightshade427
    @nightshade427 7 місяців тому

    Can you use this to conditionally auto import different files for a js import based on dev/prod/test? Eg. database_dev.js vs database_prod.js but in nuxt refer to database only, but have it auto import the correct file

    • @TheAlexLichter
      @TheAlexLichter  6 місяців тому +1

      Never tried that but I think this is possible, yes!

  • @FrierTuck-o1n
    @FrierTuck-o1n 3 місяці тому

    Quick Nick

  • @randomtimessomehow
    @randomtimessomehow 3 місяці тому

    I have set up a cron job in /cron/some-job.ts. Is it possible to define that this cronjob should only run in the prod environment?

  • @rrd_webmania
    @rrd_webmania 6 місяців тому

    awesome. thanks