Registry / devops / weboptimizer

weboptimizer

JSON →
library3.0.21jsnpmunverified

Weboptimizer is a comprehensive web optimization and module bundling solution, acting as a highly configurable wrapper around Webpack 5+. The current stable version is 3.0.21, with an active release cadence focusing on ongoing development and maintenance. It aims to streamline the development workflow by providing preconfigured support for various web technologies, including HTML, CSS (via PostCSS), JavaScript (via Babel and Flow), and templating (via EJS), handling both preprocessing and postprocessing (minification, image compression). A key differentiator is its emphasis on consolidating configuration within the `package.json` file, aiming to simplify setup compared to traditional, extensive Webpack configurations. It supports building for both library and web targets out of the box and includes features like automatic image sprite generation, providing a robust environment for web-related or Node.js projects.

npm install weboptimizer
INSTALL
IMPORT
SIG · WEBOPTIMIZER
W
weboptimizer
devopsjavascriptv3.0.21
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.

default
import weboptimizer from 'weboptimizer';
const weboptimizer = require('weboptimizer');
Weboptimizer is primarily designed for ESM environments with Node.js >=24. While CommonJS might function in some legacy Webpack setups, ESM `import` syntax is strongly recommended and idiomatic for v3+.
Weboptimizer Configuration Function
import weboptimizer from 'weboptimizer';
The default export is typically a function that, when called, generates a Webpack configuration object. It often infers settings from your project's `package.json`.
WeboptimizerConfig (Type)
import type { WeboptimizerConfig } from 'weboptimizer';
For TypeScript projects, use `import type` to import the configuration interface for better type safety when extending or modifying the output of the weboptimizer function.

Demonstrates how to generate a Webpack configuration using weboptimizer, showcasing its role as a high-level wrapper that can leverage `package.json` for primary configuration.

import weboptimizer from 'weboptimizer'; import path from 'path'; /** * A minimal webpack.config.ts for weboptimizer. * weboptimizer is designed to read much of its configuration from your package.json. * This file primarily serves as an entry point to invoke weboptimizer's configuration generation. */ export default async (env: { mode?: string }, argv: { [key: string]: any }) => { const mode = env.mode || 'development'; process.env.NODE_ENV = mode; console.log(`Weboptimizer: Configuring Webpack for ${mode} mode.`); // Call the default exported function from weboptimizer to generate the Webpack config. // weboptimizer will automatically apply many sensible defaults and read further // configuration from your project's package.json file. const config = await weboptimizer({ // Basic entry/output can be overridden here, or defined in package.json. // weboptimizer often auto-configures based on project structure. entry: path.resolve(__dirname, 'src/index.ts'), output: { path: path.resolve(__dirname, 'dist'), filename: '[name].[contenthash].js', clean: true, }, mode: mode, // weboptimizer transparently handles common loaders (e.g., Babel, PostCSS, TypeScript) // and plugins (e.g., minification, image optimization) based on detected file types // and your package.json settings. }); return config; };
weboptimizer --version
Debug
Known issues
breakingWeboptimizer v3+ requires Node.js version 24 or higher. Older Node.js versions are not supported and will lead to errors.
fix
Upgrade your Node.js environment to version 24 or newer (e.g., `nvm install 24 && nvm use 24`).
affects: >=3.0.0
breakingThis version of weboptimizer is built specifically for Webpack 5+. Projects using older Webpack versions will encounter compatibility issues.
fix
Ensure your project's `webpack` and related core plugins are updated to version 5 or higher.
affects: >=3.0.0
gotchaWeboptimizer has an extensive list of peer dependencies, including `@babel/eslint-parser`, `eslint`, `jest`, `postcss`, `webpack-dev-server`, and `imagemin`. These must be manually installed in your project.
fix
Install all required peer dependencies using `npm install [list-of-peer-dependencies]` to ensure full functionality and avoid 'module not found' errors.
affects: >=3.0.0
gotchaWeboptimizer heavily relies on `package.json` for its primary configuration, deviating from traditional `webpack.config.js` setups. This abstraction can be a footgun if users expect full granular control directly in `webpack.config.js`.
fix
Familiarize yourself with the `weboptimizer` documentation on `package.json` configuration to understand how to customize its behavior. Use the `webpack.config.ts` primarily for advanced overrides or conditional logic.
affects: >=3.0.0
gotchaThe library is licensed under a Creative Commons Naming 3.0 Unported License. This is not a typical open-source software license and may require specific attribution or have different implications for commercial use compared to MIT or Apache licenses.
fix
Review the full license text at `https://creativecommons.org/licenses/by/3.0/deed.de` to ensure compliance with its terms, especially regarding attribution.
affects: *
Errors
Common errors & fixes
Error: Cannot find module 'webpack'
One or more of weboptimizer's core peer dependencies (like 'webpack', 'webpack-cli', or 'webpack-dev-server') are not installed in your project.
fix
Install the missing peer dependencies: `npm install webpack webpack-cli webpack-dev-server` (add others as indicated by your specific build output).
ERR_REQUIRE_ESM is not defined in ES module scope
You are attempting to use CommonJS `require()` syntax with weboptimizer, which is an ESM-first package, or your project's Webpack configuration is not set up for ESM.
fix
Update your Webpack configuration files (`webpack.config.js` or `webpack.config.ts`) to use `import` statements. Ensure your project and Node.js environment are configured for ES Modules.
Error: weboptimizer requires Node.js version 24 or higher. You are currently running vX.Y.Z.
The Node.js version being used to run weboptimizer (or your build script) is older than the minimum required version 24.
fix
Upgrade your Node.js installation to version 24 or higher. Tools like NVM (Node Version Manager) can help: `nvm install 24 && nvm use 24`.
Upgrade
Version history
3.0.21latest on npm
Audit
Dependencies
webpack-dev-serverrequiredRequired for a local development server, a core part of the development environment features.
eslintrequiredEssential for JavaScript/TypeScript linting, a key feature of its integrated development workflow.
jestrequiredNeeded for unit and integration testing, as it includes preconfigured testing capabilities.
postcssrequiredCentral to CSS preprocessing, as weboptimizer natively supports PostCSS for stylesheets.
@babel/eslint-parserrequiredNecessary for JavaScript parsing and linting, especially for modern JS and React projects.
imageminrequiredRequired for image optimization and compression features bundled with the optimizer.
@types/noderequiredCrucial for TypeScript development, providing Node.js type definitions.
Agent activity
8 hits · last 30 days
node
6
OpenAI (training)
1
Resources