我想在使用react-boilerplate时添加自定义环境变量。在我的DEV环境中,我会将API指向我的localhost后端,但在PROD环境中,我会将其指向PROD后端。我尝试过使用dotenv-webpack和react-scripts,但仍然不起作用。对于dotenv-webpack,我在dllPlugin下面添加了插件代码。
dllPlugin: {
...
},
plugins: [
new Dotenv({
path: './.env', // Path to .env file (this is the default)
systemvars: true,
safe: true // load .env.example (defaults to "false" which does not use dotenv-safe)
})
]
...有没有人成功应用了这个特性?请给我一些启发..
发布于 2017-11-24 15:18:05
我已经成功地在react-boilerplate中实现了dotenv-webpack。在我把配置放错/config.js之前。现在我放入了webpack/webpack.base.babel.js。
https://stackoverflow.com/questions/47406093
复制相似问题