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

Merged
merged 1 commit into from
Dec 2, 2024
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
with:
node-version: 18
cache: npm
- run: npm ci && npm run build:prod
- run: npm ci && npm run build:dist
# build the wheel
- uses: actions/setup-python@v5
with:
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "rdmo",
"scripts": {
"build:dist": "webpack --config webpack.config.js --mode production --env ignore-perf --fail-on-warnings",
"build:prod": "webpack --config webpack.config.js --mode production",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest that build:prod fails on warnings and testing does not, but contains the performance hints.

Copy link
Member Author

@MyPyDavid MyPyDavid Nov 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ive added an object ignorePerformanceWarnings that build:prod build:dist gets so that it can fail on other warnings

"build": "webpack --config webpack.config.js --mode development",
"watch": "webpack --config webpack.config.js --mode development --watch"
Expand Down
34 changes: 29 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,39 @@ 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':
// used for build and watch
return merge(config, baseConfig, developmentConfig)

case 'production':
if (env && env['ignore-perf']) {
// build:dist will ignore performance warnings but fails on other warnings
return merge(config, baseConfig, productionConfig, ignorePerformanceWarnings)
}
// build:prod
return merge(config, baseConfig, productionConfig)

default:
throw new Error('Invalid mode')
}
})
}