Registry / devops / webpack-build

webpack-build

JSON →
library1.0.1jsnpmunverified

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.

npm install webpack-build
INSTALL
IMPORT
SIG · WEBPACK-BUILD
W
webpack-build
devopsjavascriptv1.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

build
const build = require('webpack-build');
import build from 'webpack-build';
This package is CommonJS-only in its 1.x version.
build.options.defaults
const build = require('webpack-build'); build.options.defaults = { /* ... */ };
import { options } from 'webpack-build';
Configuration defaults are set directly on the 'build' object, not via named import.

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.

const build = require('webpack-build'); const path = require('path'); const fs = require('fs'); // Create a dummy webpack.config.js for demonstration const configPath = path.join(__dirname, 'webpack.config.js'); const dummyConfigContent = ` module.exports = function(opts) { return { entry: './src/index.js', output: { path: opts.outputPath || path.join(__dirname, 'dist'), filename: 'bundle.js' }, mode: 'development' // Webpack 4+ needs mode }; }; `; // Create a dummy entry file const srcDir = path.join(__dirname, 'src'); if (!fs.existsSync(srcDir)) fs.mkdirSync(srcDir); fs.writeFileSync(path.join(srcDir, 'index.js'), 'console.log("Hello from webpack-build!");'); fs.writeFileSync(configPath, dummyConfigContent); console.log('Starting webpack-build...'); build({ config: configPath, watch: false, // Set to true to enable watching outputPath: path.join(__dirname, 'output'), context: { debug: true } }, function(err, data) { if (err) { console.error('Build failed:', err); return; } console.log('Build successful!'); console.log('Generated assets:', data.assets); // Clean up dummy files fs.unlinkSync(path.join(srcDir, 'index.js')); fs.rmdirSync(srcDir); fs.unlinkSync(configPath); fs.rmdirSync(path.join(__dirname, 'output'), { recursive: true }); });
webpack-build --version
Debug
Known issues
gotchaThis 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`).
fix
npm install webpack@'^1.9.0' # or a compatible version for your project
affects: >=1.0.0
gotchaWebpack 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.
fix
Ensure your webpack config file starts with `module.exports = function(opts) { ... return config; };`
affects: >=1.0.0
gotchaThe `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.
fix
Do not confuse `data.buildHash` with Webpack's asset hashes for cache busting or content verification.
affects: >=1.0.0
gotchaTo 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.
fix
Pass custom data like: `build({ config: '...', context: { myData: 'value' } }, ...)`
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'webpack-build'
The `webpack-build` package is not installed or not resolvable in the current environment.
fix
npm install webpack-build
Error: Cannot find module 'webpack' from '/path/to/node_modules/webpack-build'
The `webpack` peer dependency is missing from your project's `node_modules`.
fix
npm install webpack
TypeError: config is not a function
Your Webpack configuration file (`config` option) exports a static object instead of a function.
fix
Modify your webpack config file to `module.exports = function(opts) { return { /* webpack config */ }; };`
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies
webpackrequiredCore dependency; this package wraps webpack's functionality.
Agent activity
7 hits · last 30 days
node
6
OpenAI (training)
1
Resources
webpack-build — npm install webpack-build · libregistry