Skip to content

Commit dd303b2

Browse files
authored
Merge pull request element-hq#17003 from vector-im/jryans/node-env-develop
Fix `NODE_ENV` value for CI environments
2 parents 4d6a8f9 + 53f9895 commit dd303b2

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

scripts/ci_package.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ JSSDK_SHA=$(cd node_modules/matrix-js-sdk; git rev-parse --short=12 HEAD)
1414

1515
VECTOR_SHA=$(git rev-parse --short=12 HEAD) # use the ACTUAL SHA rather than assume develop
1616

17-
CI_PACKAGE=true DIST_VERSION=$VECTOR_SHA-react-$REACT_SHA-js-$JSSDK_SHA scripts/package.sh -d
17+
CI_PACKAGE=true DIST_VERSION=$VECTOR_SHA-react-$REACT_SHA-js-$JSSDK_SHA scripts/package.sh

webpack.config.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const additionalPlugins = [
1313
];
1414

1515
module.exports = (env, argv) => {
16+
let nodeEnv = argv.mode;
1617
if (process.env.CI_PACKAGE) {
1718
// Don't run minification for CI builds (this is only set for runs on develop)
1819
// We override this via environment variable to avoid duplicating the scripts
@@ -24,14 +25,7 @@ module.exports = (env, argv) => {
2425
// when working on the app but adds significant runtime overhead
2526
// We want to use the React production build but not compile the whole
2627
// application to productions standards
27-
additionalPlugins.concat([
28-
new webpack.EnvironmentPlugin({
29-
"NODE_ENV": "production",
30-
}),
31-
new webpack.DefinePlugin({
32-
"process.env.NODE_ENV": "production",
33-
}),
34-
]);
28+
nodeEnv = "production";
3529
}
3630

3731
const development = {};
@@ -94,6 +88,10 @@ module.exports = (env, argv) => {
9488
// we use a CSS optimizer too and need to manage it ourselves.
9589
minimize: argv.mode === 'production',
9690
minimizer: argv.mode === 'production' ? [new TerserPlugin({}), new OptimizeCSSAssetsPlugin({})] : [],
91+
92+
// Set the value of `process.env.NODE_ENV` for libraries like React
93+
// See also https://v4.webpack.js.org/configuration/optimization/#optimizationnodeenv
94+
nodeEnv,
9795
},
9896

9997
resolve: {

0 commit comments

Comments
 (0)