Expose `env` to backend applications (#746)
Test Plan: Add `console.log(require("../../app/version").VERSION_SHORT);` to the top of `async run()` in `src/cli/commands/load.js`. Run `yarn backend` and `node bin/sourcecred.js load`, and note that it prints the current version number. Before this change, it would have raised an error: ``` Error: gitState: not a string: undefined at parseGitState (~/git/sourcecred/bin/commands/load.js:1160:64) ``` because the requisite environment variables were not included. Also, `yarn test --full` passes. wchargin-branch: backend-env
This commit is contained in:
parent
84d505ab12
commit
436cad0326
|
@ -1,9 +1,13 @@
|
||||||
// @no-flow
|
// @no-flow
|
||||||
|
|
||||||
const webpack = require("webpack");
|
const webpack = require("webpack");
|
||||||
const eslintFormatter = require("react-dev-utils/eslintFormatter");
|
const eslintFormatter = require("react-dev-utils/eslintFormatter");
|
||||||
const ModuleScopePlugin = require("react-dev-utils/ModuleScopePlugin");
|
const ModuleScopePlugin = require("react-dev-utils/ModuleScopePlugin");
|
||||||
const paths = require("./paths");
|
const paths = require("./paths");
|
||||||
const nodeExternals = require("webpack-node-externals");
|
const nodeExternals = require("webpack-node-externals");
|
||||||
|
const getClientEnvironment = require("./env");
|
||||||
|
|
||||||
|
const env = getClientEnvironment();
|
||||||
|
|
||||||
// This is the backend configuration. It builds applications that target
|
// This is the backend configuration. It builds applications that target
|
||||||
// Node and will not run in a browser.
|
// Node and will not run in a browser.
|
||||||
|
@ -70,11 +74,5 @@ module.exports = (outputPath) => ({
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [new webpack.DefinePlugin(env.stringified)],
|
||||||
new webpack.DefinePlugin({
|
|
||||||
"process.env.NODE_ENV": JSON.stringify(
|
|
||||||
process.env.NODE_ENV || "development"
|
|
||||||
),
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue