{"id":20735,"library":"webpack-config-utils","title":"webpack-config-utils","description":"Utilities to make webpack configuration objects easier to compose and read. Current stable version is 2.3.1. The package provides helper functions like getIfUtils, removeEmpty, and props to conditionally include parts of the config based on environment. It differentiates from plain webpack config by reducing conditional logic and removing empty entries. Last release was in 2016; no further development. Works with webpack 1, 2, and 3.","status":"active","version":"2.3.1","language":"javascript","source_language":"en","source_url":"https://github.com/kentcdodds/webpack-config-utils","tags":["javascript"],"install":[{"cmd":"npm install webpack-config-utils","lang":"bash","label":"npm"},{"cmd":"yarn add webpack-config-utils","lang":"bash","label":"yarn"},{"cmd":"pnpm add webpack-config-utils","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"CommonJS only; does not support ESM imports.","wrong":"import { getIfUtils } from 'webpack-config-utils'","symbol":"getIfUtils","correct":"const { getIfUtils } = require('webpack-config-utils')"},{"note":"Both work, but destructuring is idiomatic.","wrong":"const removeEmpty = require('webpack-config-utils').removeEmpty","symbol":"removeEmpty","correct":"const { removeEmpty } = require('webpack-config-utils')"},{"note":"Props is exported as a named export from the main entry.","wrong":"const props = require('webpack-config-utils/props')","symbol":"props","correct":"const { props } = require('webpack-config-utils')"}],"quickstart":{"code":"const { getIfUtils, removeEmpty } = require('webpack-config-utils');\nconst webpack = require('webpack');\n\nconst { ifProduction, ifNotProduction } = getIfUtils(process.env.NODE_ENV);\n\nmodule.exports = {\n  mode: ifProduction('production', 'development'),\n  entry: removeEmpty({\n    app: ifProduction('./indexWithoutCSS', './indexWithCSS'),\n    css: ifProduction('./style.scss')\n  }),\n  output: {\n    chunkFilename: ifProduction('js/[id].[contenthash].js', 'js/[name].js'),\n    filename: ifProduction('js/[id].[contenthash].js', 'js/[name].js'),\n  },\n  plugins: removeEmpty([\n    ifProduction(new webpack.DefinePlugin({\n      'process.env': { NODE_ENV: '\"production\"' }\n    }))\n  ])\n};","lang":"javascript","description":"Shows how to use getIfUtils and removeEmpty to conditionally configure a webpack config based on NODE_ENV."},"warnings":[{"fix":"Do not use 'here' from this package; use path.resolve instead.","message":"v2.0.0 removed the 'here' export.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Consider alternatives like webpack-merge or webpack-chain for more comprehensive config management.","message":"The package is no longer maintained; last release in 2016.","severity":"deprecated","affected_versions":"*"},{"fix":"Use getIfUtils(env) where env is the object from CLI --env flags.","message":"getIfUtils expects a string or object with keys, not an env from --env; with webpack 2+, pass env directly.","severity":"gotcha","affected_versions":"*"},{"fix":"Manually filter or use a different helper if you need to remove empty strings.","message":"removeEmpty only removes undefined and null, not empty strings or arrays.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use const { getIfUtils } = require('webpack-config-utils');","cause":"Importing incorrectly or destructuring from wrong source.","error":"TypeError: getIfUtils is not a function"},{"fix":"Run npm install --save-dev webpack-config-utils","cause":"Package not installed.","error":"Cannot find module 'webpack-config-utils'"},{"fix":"Ensure process.env.NODE_ENV is set or pass a valid string.","cause":"Passing undefined or wrong argument to getIfUtils.","error":"Unhandled rejection: TypeError: Cannot read property 'production' of undefined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}