nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.17k stars 2.31k forks source link

Define environment variables without the NX_ prefix #14719

Closed pax-k closed 10 months ago

pax-k commented 1 year ago

I'm using a React dependency which expects a specific environment variable name to be set. Having to prefix with NX_ won't work. Tried something like: (storybook configured inside an nx react ui lib)

    "storybook-with-custom-env-var": {
      "executor": "nx:run-commands",
      "options": {
        "command": "SOME_SPECIFIC_VAR=true nx run libs-ui:storybook"
      }
    }

Tried also to create a separate app and placed the var inside .env, but still not present if not prefixed with NX_.

Also it would be cool to be able to define environment variables in the project.json:

    "storybook": {
      "executor": "@nrwl/storybook:storybook",
      "options": {
        "uiFramework": "@storybook/react",
        "port": 4400,
        "configDir": "packages/libs/ui/.storybook"
      },
      "configurations": {
        "ci": {
          "quiet": true,
          "env": ["SOME_SPECIFIC_VAR=true"]
        }
      }
    },

Another solution is to leverage pure yarn workspaces and integrate all the generators with in the packaged-based model. Maybe after the Lerna takeover things will go in this direction.

github-actions[bot] commented 11 months ago

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏

github-actions[bot] commented 9 months ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.