We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
微信小程序
小程序基础库: 2.12.0 使用框架: React
pacage.json内scripts使用cross-env 传递 env_type字段 为test, config/index.js内配置env_type为prod 在项目自身代码中process.env.env_type取值正常为test 在node_modules的包内使用process.env.env_type取值却为prod
pacage.json
config/index.js
// package.json "scripts": { "build": "cross-env env_type=test taro build --type weapp" } // config/index.js env: { env_type: 'prod' }
node_modules和项目自身代码使用process.env取值一致
项目自身代码process.env值为cross-env传递的值 node_modules内为config/index.js配置的值
👽 Taro v3.0.27 Taro CLI 3.0.27 environment info: System: OS: macOS 10.14.6 Shell: 5.3 - /bin/zsh Binaries: Node: 12.10.0 - /usr/local/bin/node Yarn: 1.13.0 - /usr/local/bin/yarn npm: 6.10.3 - /usr/local/bin/npm npmPackages: @tarojs/cli: 3.0.27 => 3.0.27 @tarojs/components: 3.0.27 => 3.0.27 @tarojs/mini-runner: 3.0.27 => 3.0.27 @tarojs/react: 3.0.27 => 3.0.27 @tarojs/runtime: 3.0.27 => 3.0.27 @tarojs/taro: 3.0.27 => 3.0.27 @tarojs/webpack-runner: 3.0.27 => 3.0.27 babel-preset-taro: 3.0.27 => 3.0.27 eslint-config-taro: 3.0.27 => 3.0.27 nerv-devtools: ^1.5.7 => 1.5.7 nervjs: ^1.5.7 => 1.5.7 react: 16.10.0 => 16.10.0 taro-ui: ^3.0.0-alpha.2 => 3.0.0-alpha.3
The text was updated successfully, but these errors were encountered:
config/index.js 的 env 会通过 Webpack definePlugin 设置。
env
Webpack definePlugin
可以试试:
// config/index.js env: { env_type: process.env.env_type || 'prod' }
Sorry, something went wrong.
config/index.js 的 env 会通过 Webpack definePlugin 设置。 可以试试: // config/index.js env: { env_type: process.env.env_type || 'prod' }
目前这样解决了
No branches or pull requests
相关平台
微信小程序
小程序基础库: 2.12.0
使用框架: React
复现步骤
pacage.json
内scripts使用cross-env 传递 env_type字段 为test,config/index.js
内配置env_type为prod在项目自身代码中process.env.env_type取值正常为test
在node_modules的包内使用process.env.env_type取值却为prod
期望结果
node_modules和项目自身代码使用process.env取值一致
实际结果
项目自身代码process.env值为cross-env传递的值
node_modules内为config/index.js配置的值
环境信息
The text was updated successfully, but these errors were encountered: