From da094cec3b94e4278079b32bc2d53aa3fc829108 Mon Sep 17 00:00:00 2001 From: David Wallace Date: Fri, 29 Nov 2024 10:16:18 +0100 Subject: [PATCH 1/2] build(webpack): build prod fails on warnings #1197 Signed-off-by: David Wallace --- package.json | 3 ++- webpack.config.js | 33 ++++++++++++++++++++++++++++----- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index d2e79d2b81..c7a630ba68 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,8 @@ { "name": "rdmo", "scripts": { - "build:prod": "webpack --config webpack.config.js --mode production", + "build:prod": "webpack --config webpack.config.js --mode production --fail-on-warnings", + "build:testing": "webpack --config webpack.config.js --mode production --env testing ", "build": "webpack --config webpack.config.js --mode development", "watch": "webpack --config webpack.config.js --mode development --watch" }, diff --git a/webpack.config.js b/webpack.config.js index d1d630dd32..bf06aa321b 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -108,6 +108,7 @@ const developmentConfig = { // special config for production const productionConfig = { + bail: true, // Stop the build on errors plugins: [ new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('production') @@ -116,16 +117,38 @@ const productionConfig = { optimization: { minimize: true, minimizer: [new TerserPlugin()] - } + }, +} + +const ignorePerformanceWarnings = { + performance: { + hints: false // Suppress performance warnings in prod + }, + ignoreWarnings: [ // ignore performance issues + { message: /performance recommendations/ }, + { message: /asset size limit/ }, + { message: /entrypoint size limit/ } + ] } // combine config depending on the provided --mode command line option module.exports = (env, argv) => { return configList.map(config => { - if (argv.mode === 'development') { - return merge(config, baseConfig, developmentConfig) - } else { - return merge(config, baseConfig, productionConfig) + switch (argv.mode) { + + case 'development': + return merge(config, baseConfig, developmentConfig) + + case 'production': + // testing mode is enabled via --env testing + if (env && env.testing) { + return merge(config, baseConfig, productionConfig) + } + // build:prod will fail on warnings, performance warnings are ignored + return merge(config, baseConfig, productionConfig, ignorePerformanceWarnings) + + default: + throw new Error('Invalid mode') } }) } From dff15085b5e9a6070e81d6bb86a356c31a6f11a8 Mon Sep 17 00:00:00 2001 From: David Wallace Date: Fri, 29 Nov 2024 10:16:38 +0100 Subject: [PATCH 2/2] undo this commit, it should fail the build Signed-off-by: David Wallace --- .../assets/js/projects/components/helper/PendingInvitations.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rdmo/projects/assets/js/projects/components/helper/PendingInvitations.js b/rdmo/projects/assets/js/projects/components/helper/PendingInvitations.js index d7322fdee5..6338e0eb7c 100644 --- a/rdmo/projects/assets/js/projects/components/helper/PendingInvitations.js +++ b/rdmo/projects/assets/js/projects/components/helper/PendingInvitations.js @@ -1,7 +1,7 @@ import React from 'react' import PropTypes from 'prop-types' -import { baseUrl } from 'rdmo/core/assets/js/utils/meta' +import baseUrl from 'rdmo/core/assets/js/utils/meta' import { ROLE_LABELS } from '../../utils'