Skip to content

Commit

Permalink
build(webpack): fail on filtered warnings for build prod
Browse files Browse the repository at this point in the history
Signed-off-by: David Wallace <[email protected]>
  • Loading branch information
MyPyDavid committed Nov 27, 2024
1 parent cde2c42 commit c9dfbd3
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ const baseConfig = {
output: {
filename: 'js/[name].js'
},
stats: {
warnings: true, // Show warnings
errors: true, // Show errors
errorDetails: true // Include stack traces and details
},
plugins: [
new MiniCssExtractPlugin({
filename: 'css/[name].css',
Expand Down Expand Up @@ -103,7 +108,11 @@ const developmentConfig = {
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('development')
})
]
],
performance: {
hints: 'warning' // Show performance warnings in development
},
ignoreWarnings: [] // No warnings are ignored in development
}

// special config for production
Expand All @@ -113,10 +122,19 @@ const productionConfig = {
'process.env.NODE_ENV': JSON.stringify('production')
})
],
optimization: {
optimization: {
minimize: true,
minimizer: [new TerserPlugin()]
}
minimizer: [new TerserPlugin()],
emitOnErrors: true // Fail build on errors
},
performance: {
hints: false // Suppress performance warnings in production
},
ignoreWarnings: [ // Suppress several warnings
{ message: /performance recommendations/ },
{ message: /asset size limit/ },
{ message: /entrypoint size limit/ }
]
}

// combine config depending on the provided --mode command line option
Expand Down

0 comments on commit c9dfbd3

Please sign in to comment.