Skip to content

Commit 4d6a8f9

Browse files
authored
Merge pull request element-hq#16969 from vector-im/gsouquet-nightly-react-prod
2 parents e4c9444 + 84d6dcf commit 4d6a8f9

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

webpack.config.js

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ const TerserPlugin = require('terser-webpack-plugin');
55
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
66
const webpack = require("webpack");
77

8-
let og_image_url = process.env.RIOT_OG_IMAGE_URL;
9-
if (!og_image_url) og_image_url = 'https://app.element.io/themes/element/img/logos/opengraph.png';
8+
let ogImageUrl = process.env.RIOT_OG_IMAGE_URL;
9+
if (!ogImageUrl) ogImageUrl = 'https://app.element.io/themes/element/img/logos/opengraph.png';
1010

1111
const additionalPlugins = [
1212
// This is where you can put your customisation replacements.
@@ -18,6 +18,20 @@ module.exports = (env, argv) => {
1818
// We override this via environment variable to avoid duplicating the scripts
1919
// in `package.json` just for a different mode.
2020
argv.mode = "development";
21+
22+
// More and more people are using nightly build as their main client
23+
// Libraries like React have a development build that is useful
24+
// when working on the app but adds significant runtime overhead
25+
// We want to use the React production build but not compile the whole
26+
// 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+
]);
2135
}
2236

2337
const development = {};
@@ -152,8 +166,8 @@ module.exports = (env, argv) => {
152166
},
153167
loader: 'babel-loader',
154168
options: {
155-
cacheDirectory: true
156-
}
169+
cacheDirectory: true,
170+
},
157171
},
158172
{
159173
test: /\.css$/,
@@ -164,7 +178,7 @@ module.exports = (env, argv) => {
164178
options: {
165179
importLoaders: 1,
166180
sourceMap: true,
167-
}
181+
},
168182
},
169183
{
170184
loader: 'postcss-loader',
@@ -202,7 +216,7 @@ module.exports = (env, argv) => {
202216
"local-plugins": true,
203217
},
204218
},
205-
]
219+
],
206220
},
207221
{
208222
test: /\.scss$/,
@@ -213,7 +227,7 @@ module.exports = (env, argv) => {
213227
options: {
214228
importLoaders: 1,
215229
sourceMap: true,
216-
}
230+
},
217231
},
218232
{
219233
loader: 'postcss-loader',
@@ -241,7 +255,7 @@ module.exports = (env, argv) => {
241255
"local-plugins": true,
242256
},
243257
},
244-
]
258+
],
245259
},
246260
{
247261
test: /\.wasm$/,
@@ -311,7 +325,7 @@ module.exports = (env, argv) => {
311325
},
312326
],
313327
},
314-
]
328+
],
315329
},
316330

317331
plugins: [
@@ -332,7 +346,7 @@ module.exports = (env, argv) => {
332346
excludeChunks: ['mobileguide', 'usercontent', 'jitsi'],
333347
minify: argv.mode === 'production',
334348
vars: {
335-
og_image_url: og_image_url,
349+
og_image_url: ogImageUrl,
336350
},
337351
}),
338352

@@ -438,6 +452,7 @@ function getAssetOutputPath(url, resourcePath) {
438452
* be placed directly into things like CSS files.
439453
*
440454
* @param {string} path Some path to a file.
455+
* @returns {string} converted path
441456
*/
442457
function toPublicPath(path) {
443458
return path.replace(/\\/g, '/');

0 commit comments

Comments
 (0)