Giter Site home page Giter Site logo

Comments (5)

juliusmarminge avatar juliusmarminge commented on June 8, 2024 1

packages/api doesn't have any build step.

it also doesn't run any code on it's own right? so the next app will load the envs for you.

check out create-t3-turbo where i do this:

https://github.com/t3-oss/create-t3-turbo/blob/main/apps/nextjs/package.json#L7
https://github.com/t3-oss/create-t3-turbo/blob/main/packages/auth/env.ts
https://github.com/t3-oss/create-t3-turbo/blob/main/apps/nextjs/next.config.js#L7

from t3-env.

juliusmarminge avatar juliusmarminge commented on June 8, 2024
{
  "scripts": {
    "with-env": "dotenv -e ../../.env --",
    "build": "pnpm with-env next build"
  }
}

should work

from t3-env.

gokaygurcan avatar gokaygurcan commented on June 8, 2024

Hi @juliusmarminge,

Thanks for your reply.

I'm not sure about it. packages/api doesn't have any build step. This would work for apps/next for sure, and I tried similar things with dotenv and dotenv-expand, but it's not solving the issue I'm describing above I think.

In none of my attempts, I was able to make env.mjs in packages/api to read relevant values from root .env file.

from t3-env.

gokaygurcan avatar gokaygurcan commented on June 8, 2024

Hi again,

I followed this approach and ended up in a very weird place now. It's working as expected here, https://codesandbox.io/p/devbox/ecstatic-pascal-wxcffg and not on my local machine. I guess for the sake of this issue, we can say it's no longer an issue. But it's still weird to get two different results with the very same code. I'll keep looking if I have something else installed that causes this discrepancy.

Thanks a lot, closing the issue now.

from t3-env.

gokaygurcan avatar gokaygurcan commented on June 8, 2024

Update: eventually, i created a separate folder packages/env and moved everything under that. Instead of using it like import { env } from @/env.mjs i'm using it like import { env } from '@something/env now. Next step is to split it even further and import only relevant pieces if possible.

After trying a few options, this felt like the best approach so far. Throwing it here, in case someone needs any guidance in the future.

from t3-env.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.