nrwl/nx

nx build exposed system variables - define_process_env_default

Opened this issue · 0 comments

Current Behavior

is there away to not include these environment variables from the build files define_process_env_default? I am using React Vite. i'm just concern that my folders or other system variables are exposed in client side.

var define_process_env_default = {
  NX_CLI_SET: "true",
  NVM_INC: "/Users/<user>/.nvm/versions/node/v18.17.0/include/node",
  NX_LOAD_DOT_ENV_FILES: "true",
  TERM_PROGRAM: "vscode",
  PROJECT_CWD: "/Users/<user>/Documents/<project-name>/FrontEnd",
  INIT_CWD: "/Users/<user>/Documents/<project-name>/FrontEnd",
  NVM_CD_FLAGS: "-q",
  TERM: "xterm-256color",
  SHELL: "/bin/zsh",
  HOMEBREW_REPOSITORY: "/opt/homebrew",
  TMPDIR: "/var/folders/lj/xxxxxx7d7zdxxxxxx_6_kq2rxxxxxx/T/",
  TERM_PROGRAM_VERSION: "1.91.1",
  FPATH:
    "/Users/<user>/.oh-my-zsh/plugins/git:/Users/<user>/.oh-my-zsh/functions:/Users/<user>/.oh-my-zsh/completions:/Users/<user>/.oh-my-zsh/custom/functions:/Users/<user>/.oh-my-zsh/custom/completions:/Users/<user>/.oh-my-zsh/plugins/git:/Users/<user>/.oh-my-zsh/functions:/Users/<user>/.oh-my-zsh/completions:/Users/<user>/.oh-my-zsh/custom/functions:/Users/<user>/.oh-my-zsh/custom/completions:/Users/<user>/.oh-my-zsh/cache/completions:/Users/<user>/.zsh/completions:/usr/local/share/zsh/site-functions:/usr/share/zsh/site-functions:/usr/share/zsh/5.9/functions",
  ZDOTDIR: "/Users/<user>",
  ORIGINAL_XDG_CURRENT_DESKTOP: "undefined",
  MallocNanoZone: "0",
  NX_TASK_TARGET_TARGET: "build",
  PNPM_HOME: "/Users/<user>/Library/pnpm",
  ZSH: "/Users/<user>/.oh-my-zsh",
  NVM_DIR: "/Users/<user>/.nvm",
  USER: "<user>",
  LS_COLORS:
    "di=xx;36:ln=xx:so=xx:pi=xx:ex=xx:bd=xx;46:cd=xx;43:su=xx;41:sg=xx;46:tw=xx;42:ow=xx;43",
  COMMAND_MODE: "unix2003",
  NX_TASK_HASH: "5882000901130000000",
  SSH_AUTH_SOCK: "/private/tmp/com.apple.launchd.xxxxxaP0mv/Listeners",
  __CF_USER_TEXT_ENCODING: "0x1F7:0x0:0x0",
  npm_execpath:
    "/private/var/folders/lj/xxxxxx7d7zdxxxxxx_6_kq2rxxxxxx/T/xxx-xxx00000/yarn",
  PAGER: "less",
  LSCOLORS: "Gxfxcxdxbxegedabagacad",
  NX_TASK_TARGET_PROJECT: "<app-name>",
  PATH: "/Users/<user>/Documents/<project-name>/FrontEnd/apps/<app-name>/node_modules/.bin:/Users/<user>/Documents/<project-name>/FrontEnd/apps/node_modules/.bin:/Users/<user>/Documents/<project-name>/FrontEnd/node_modules/.bin:/Users/<user>/Documents/<project-name>/node_modules/.bin:/Users/<user>/Documents/projects/node_modules/.bin:/Users/<user>/Documents/node_modules/.bin:/Users/<user>/node_modules/.bin:/Users/node_modules/.bin:/node_modules/.bin:/Users/<user>/.nvm/versions/node/v18.17.0/bin:/private/var/folders/lj/xxxxxx7d7zdxxxxxx_6_kq2rxxxxxx/T/xxx-xxx00000:/Users/<user>/.nvm/versions/node/v18.17.0/bin:/Library/Frameworks/Python.framework/Versions/3.12/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/usr/local/sbin:/Users/<user>/Library/pnpm:/Users/<user>/.deno/bin:/Users/<user>/.nvm/versions/node/v18.17.0/bin:/Library/Frameworks/Python.framework/Versions/3.12/bin:/opt/homebrew/bin:/opt/homebrew/sbin",
  NX_WORKSPACE_ROOT: "/Users/<user>/Documents/<project-name>/FrontEnd",
  npm_package_json:
    "/Users/<user>/Documents/<project-name>/FrontEnd/package.json",
  _: "/Users/<user>/Documents/<project-name>/FrontEnd/node_modules/.bin/vite",
  USER_ZDOTDIR: "/Users/<user>",
  __CFBundleIdentifier: "com.microsoft.VSCode",
  PWD: "/Users/<user>/Documents/<project-name>/FrontEnd/apps/<app-name>",
  npm_package_name: "<package-name>",
  LANG: "en_US.UTF-8",
  VSCODE_GIT_ASKPASS_EXTRA_ARGS: "",
  XPC_FLAGS: "0x0",
  FORCE_COLOR: "true",
  npm_package_version: "2.3.1",
  XPC_SERVICE_NAME: "0",
  VSCODE_INJECTION: "1",
  SHLVL: "2",
  HOME: "/Users/<user>",
  VSCODE_GIT_ASKPASS_MAIN:
    "/private/var/folders/lj/xxxxxx7d7zdxxxxxx_6_kq2rxxxxxx/T/AppTranslocation/XXXXXXXX-XXXX-XXXX-XXXX-XXXXX93865F3/d/Visual Studio Code.app/Contents/Resources/app/extensions/git/dist/askpass-main.js",
  HOMEBREW_PREFIX: "/opt/homebrew",
  LESS: "-R",
  LOGNAME: "<user>",
  BERRY_BIN_FOLDER:
    "/private/var/folders/lj/xxxxxx7d7zdxxxxxx_6_kq2rxxxxxx/T/xxx-xxx00000",
  VSCODE_GIT_IPC_HANDLE:
    "/var/folders/lj/xxxxxx7d7zdxxxxxx_6_kq2rxxxxxx/T/vscode-git-ed769ef513.sock",
  LERNA_PACKAGE_NAME: "<app-name>",
  NVM_BIN: "/Users/<user>/.nvm/versions/node/v18.17.0/bin",
  npm_config_user_agent: "yarn/4.3.1 npm/? node/v18.17.0 darwin arm64",
  VSCODE_GIT_ASKPASS_NODE:
    "/private/var/folders/lj/xxxxxx7d7zdxxxxxx_6_kq2rxxxxxx/T/AppTranslocation/XXXXXXXX-XXXX-XXXX-XXXX-XXXXX93865F3/d/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin)",
  GIT_ASKPASS:
    "/private/var/folders/lj/xxxxxx7d7zdxxxxxx_6_kq2rxxxxxx/T/AppTranslocation/XXXXXXXX-XXXX-XXXX-XXXX-XXXXX93865F3/d/Visual Studio Code.app/Contents/Resources/app/extensions/git/dist/askpass.sh",
  INFOPATH: "/opt/homebrew/share/info:/opt/homebrew/share/info:",
  HOMEBREW_CELLAR: "/opt/homebrew/Cellar",
  npm_node_execpath:
    "/private/var/folders/lj/xxxxxx7d7zdxxxxxx_6_kq2rxxxxxx/T/xxx-xxx00000/node",
  COLORTERM: "truecolor",
  NODE_ENV: "production",
};

Expected Behavior

should not include these environment variables

GitHub Repo

No response

Steps to Reproduce

  1. vite.config.ts
  build: {
    outDir: '../../dist/apps/<app-name>',
    emptyOutDir: true,
    reportCompressedSize: true,
    commonjsOptions: {
      transformMixedEsModules: true,
    },
  },
  1. Run nx run-many -t build
  2. Check build folders /dist/ search for define_process_env_default

Nx Report

Node   : 18.17.0
OS     : darwin-arm64
yarn   : 4.3.1

nx                 : 19.5.1
@nx/js             : 19.5.1
@nx/jest           : 19.5.1
@nx/linter         : 19.5.1
@nx/eslint         : 19.5.1
@nx/workspace      : 19.5.1
@nx/cypress        : 19.8.6
@nx/devkit         : 19.5.1
@nx/eslint-plugin  : 19.5.1
@nx/react          : 19.5.1
@nx/storybook      : 19.8.6
@nrwl/tao          : 19.5.1
@nx/vite           : 19.5.1
@nx/web            : 19.5.1
typescript         : 5.5.3
---------------------------------------
Registered Plugins:
@nx/vite/plugin
@nx/eslint/plugin
@nx/jest/plugin
@nx/storybook/plugin

Failure Logs

Package Manager Version

yarn 4.3.1

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response