webpack-nano
raw JSON → 1.1.1 verified Sat Apr 25 auth: no javascript
A minimal, lightweight CLI for webpack that focuses on configuration file use, allowing unlimited custom command-line flags via the webpack-nano/argv export. Current stable version is 1.1.1. It is maintained as a smaller alternative to webpack-cli, roughly 90% smaller. Supports config files in Babel, ES6, TypeScript, and ESM formats with appropriate loaders. Drops Node <10 support since v0.7.0 and includes breaking changes in v1.0.0 due to yargs-parser update affecting parsed argv output.
Common errors
error Error: Cannot find module 'webpack' ↓
cause webpack is a peer dependency but not installed.
fix
Run
npm install webpack --save-dev alongside webpack-nano. error Error: Cannot find module 'webpack-nano/argv' ↓
cause Using import from wrong path or older version without subpath export.
fix
Ensure you are using
require('webpack-nano/argv') or import { argv } from 'webpack-nano/argv'. Requires webpack-nano >=0.5.0. error TypeError: Cannot destructure property 'argv' of 'undefined' or 'null' ↓
cause Attempting to destructure argv from the main package export.
fix
Use the correct subpath:
const argv = require('webpack-nano/argv') Warnings
breaking v1.0.0: yargs-parser update changes parsed argv results ↓
fix Review usage of 'webpack-nano/argv' output; ensure custom flags parse as expected under the new parser.
breaking v0.7.0: drops Node v8 support ↓
fix Use Node v10 or higher.
deprecated v0.5.0: stats colors enabled by default, excluding node_modules in stats output ↓
fix If relying on previous behavior, explicitly set `stats.colors: false` and `stats.exclude: undefined` in webpack config.
gotcha The binary name is 'wp', not 'webpack'. ↓
fix Use `npx wp` instead of `npx webpack`.
gotcha Import 'webpack-nano/argv' is not the main export; must use exact subpath. ↓
fix Use `import { argv } from 'webpack-nano/argv'` or `const argv = require('webpack-nano/argv')`.
Install
npm install webpack-nano yarn add webpack-nano pnpm add webpack-nano Imports
- default (CLI binary wp) wrong
npx webpackcorrectnpx wp - argv wrong
const argv = require('webpack-nano').argvcorrectimport { argv } from 'webpack-nano/argv' - require('webpack-nano/argv') wrong
const { argv } = require('webpack-nano')correctconst argv = require('webpack-nano/argv')
Quickstart
npm install webpack-nano webpack --save-dev
# Create webpack.config.js
module.exports = {
entry: './src/index.js',
output: { filename: 'bundle.js', path: __dirname + '/dist' }
};
# Build
npx wp --config webpack.config.js