{"id":15495,"library":"webpack-build","title":"Webpack Build Wrapper","description":"The `webpack-build` package, currently at version 1.0.1, serves as a comprehensive wrapper around Webpack, streamlining its integration into broader build systems. It distinguishes itself by offering a suite of advanced features not native to base Webpack, including the ability to run multiple concurrent Webpack compilers leveraging multiple worker processes, robust persistent caching mechanisms for significantly faster rebuilds, and a built-in build server with HMR (Hot Module Replacement) support. This tool is designed to reduce boilerplate and standardize complex build configurations by providing specific configuration hooks and a dynamic way to construct Webpack configs based on various build flags and options. It allows for overriding standard Webpack `output.path` and `publicPath`, and manages asset paths with `staticRoot` and `staticUrl` options. While its release cadence isn't explicitly stated, its 1.x version implies a stable and mature codebase focused on enhancing the Webpack development experience through structured extensibility and performance optimizations.","status":"active","version":"1.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/markfinger/webpack-build","tags":["javascript"],"install":[{"cmd":"npm install webpack-build","lang":"bash","label":"npm"},{"cmd":"yarn add webpack-build","lang":"bash","label":"yarn"},{"cmd":"pnpm add webpack-build","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core dependency; this package wraps webpack's functionality.","package":"webpack","optional":false}],"imports":[{"note":"This package is CommonJS-only in its 1.x version.","wrong":"import build from 'webpack-build';","symbol":"build","correct":"const build = require('webpack-build');"},{"note":"Configuration defaults are set directly on the 'build' object, not via named import.","wrong":"import { options } from 'webpack-build';","symbol":"build.options.defaults","correct":"const build = require('webpack-build');\nbuild.options.defaults = { /* ... */ };"}],"quickstart":{"code":"const build = require('webpack-build');\nconst path = require('path');\nconst fs = require('fs');\n\n// Create a dummy webpack.config.js for demonstration\nconst configPath = path.join(__dirname, 'webpack.config.js');\nconst dummyConfigContent = `\nmodule.exports = function(opts) {\n  return {\n    entry: './src/index.js',\n    output: {\n      path: opts.outputPath || path.join(__dirname, 'dist'),\n      filename: 'bundle.js'\n    },\n    mode: 'development' // Webpack 4+ needs mode\n  };\n};\n`;\n\n// Create a dummy entry file\nconst srcDir = path.join(__dirname, 'src');\nif (!fs.existsSync(srcDir)) fs.mkdirSync(srcDir);\nfs.writeFileSync(path.join(srcDir, 'index.js'), 'console.log(\"Hello from webpack-build!\");');\n\nfs.writeFileSync(configPath, dummyConfigContent);\n\nconsole.log('Starting webpack-build...');\nbuild({\n  config: configPath,\n  watch: false, // Set to true to enable watching\n  outputPath: path.join(__dirname, 'output'),\n  context: {\n    debug: true\n  }\n}, function(err, data) {\n  if (err) {\n    console.error('Build failed:', err);\n    return;\n  }\n  console.log('Build successful!');\n  console.log('Generated assets:', data.assets);\n  // Clean up dummy files\n  fs.unlinkSync(path.join(srcDir, 'index.js'));\n  fs.rmdirSync(srcDir);\n  fs.unlinkSync(configPath);\n  fs.rmdirSync(path.join(__dirname, 'output'), { recursive: true });\n});","lang":"javascript","description":"This example demonstrates basic usage, initializing a build with a dynamic Webpack configuration file and logging the generated assets. It also sets up a simple dummy config and source file for a runnable example."},"warnings":[{"fix":"npm install webpack@'^1.9.0' # or a compatible version for your project","message":"This package requires `webpack` as a peer dependency. Ensure it is installed in your project, compatible with `webpack-build`'s expected version range (>= 1.9 for v1.x of `webpack-build`).","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure your webpack config file starts with `module.exports = function(opts) { ... return config; };`","message":"Webpack configuration files provided to `webpack-build` must export a function that accepts an `options` object, rather than a direct Webpack configuration object. This function allows dynamic configuration based on build options.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Do not confuse `data.buildHash` with Webpack's asset hashes for cache busting or content verification.","message":"The `buildHash` provided in the `data` object upon build completion is an internal identifier used by `webpack-build` for caching and HMR. It is distinct from and unrelated to any content hashes generated by Webpack itself.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Pass custom data like: `build({ config: '...', context: { myData: 'value' } }, ...)`","message":"To pass arbitrary data into your webpack configuration function, use the `context` property within the options object passed to `build()`. This data will be available on `opts.context` inside your config function.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"npm install webpack-build","cause":"The `webpack-build` package is not installed or not resolvable in the current environment.","error":"Cannot find module 'webpack-build'"},{"fix":"npm install webpack","cause":"The `webpack` peer dependency is missing from your project's `node_modules`.","error":"Error: Cannot find module 'webpack' from '/path/to/node_modules/webpack-build'"},{"fix":"Modify your webpack config file to `module.exports = function(opts) { return { /* webpack config */ }; };`","cause":"Your Webpack configuration file (`config` option) exports a static object instead of a function.","error":"TypeError: config is not a function"}],"ecosystem":"npm"}