Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1197 npm build warnings in ci #1203

Draft
wants to merge 2 commits into
base: 2.3.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
33 changes: 28 additions & 5 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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')
}
})
}
Loading