我正在使用 React Boilerplate,并.env
在根目录中有一个单独的来表示我的服务器是开发、登台还是生产。但是,我意识到对于我的设置,这不是最好的路线。然后我了解到,在 package.json 中有一段代码实际上显示了生产环境变量,如下所示:
"babel": {
"env": {
"production": {
"only": [
"app"
],
"plugins": [
"transform-react-remove-prop-types",
"transform-react-constant-elements",
"transform-react-inline-elements"
]
},
"test": {
"plugins": [
"transform-es2015-modules-commonjs",
"dynamic-import-node"
]
}
}
}
从这里,我想添加开发和登台,但我不断收到一个 webpack 错误,上面写着
Unknown option: C:\folders\blah\project\package.json.development.VARIABLE.
A common cause of this error is the presence of a configuration options
object without the corresponding preset name. Example:
Invalid: { presets: [{option: value}] }
Valid: { presets: [['presetName', {option: value}]] }
我的补充就像
"development": {
"VARIABLE": "value"
}
任何想法?