diff --git a/package.json b/package.json index d2e79d2b8..c7a630ba6 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/rdmo/projects/assets/js/projects/components/helper/PendingInvitations.js b/rdmo/projects/assets/js/projects/components/helper/PendingInvitations.js index d7322fdee..6338e0eb7 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' diff --git a/webpack.config.js b/webpack.config.js index d1d630dd3..bf06aa321 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') } }) }