Registry / devops / cname-webpack-plugin

cname-webpack-plugin

JSON →
library3.0.0jsnpmunverified

Webpack plugin to generate a CNAME file (used by GitHub Pages, Netlify, etc.) for custom domains during build. v3.0.0 is stable, low maintenance cadence. Key differentiator: minimal, zero-config approach for adding a CNAME file to webpack output. Supports webpack 4 and 5. No dependencies beyond webpack peer.

npm install cname-webpack-plugin
INSTALL
IMPORT
SIG · CNAME-WEBPACK-PLUG
C
cname-webpack-plugin
devopsjavascriptv3.0.0
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.

CnameWebpackPlugin
const CnameWebpackPlugin = require('cname-webpack-plugin');
import CnameWebpackPlugin from 'cname-webpack-plugin';
ESM import available in v3+? Actually this package is CJS-only, do not default import.
CnameWebpackPlugin
import CnameWebpackPlugin from 'cname-webpack-plugin';
const { CnameWebpackPlugin } = require('cname-webpack-plugin');
For ESM projects, use default import. Common mistake is destructuring require.
CnameWebpackPlugin (type)
import type { CnameWebpackPlugin } from 'cname-webpack-plugin';
TypeScript users: type import only exists if types are provided. Package does not ship types; use @types/cname-webpack-plugin.

Shows basic usage: import plugin, add to webpack plugins array with domain option.

// webpack.config.js const CnameWebpackPlugin = require('cname-webpack-plugin'); module.exports = { entry: './src/index.js', output: { filename: 'bundle.js', path: __dirname + '/dist', }, plugins: [ new CnameWebpackPlugin({ domain: 'example.com', }), ], };
Debug
Known issues
breakingVersion 1.x used a different API: new CnamePlugin(); v2+ renamed to CnameWebpackPlugin.
fix
Rename import/require to CnameWebpackPlugin and update constructor call.
affects: <=1.0.0
gotchaPlugin does not validate domain format; invalid domain will produce a malformed CNAME file.
fix
Ensure domain is a valid hostname (e.g., 'example.com' without protocol or trailing slash).
affects: >=2.0.0
gotchaPlugin writes only to the main output path; does not work with multi-compiler or multi-output configs.
fix
Use one plugin instance per compiler or manually handle with multiple compilations.
affects: >=2.0.0
deprecatedWebpack 4 support will be removed in future major version; upgrade to webpack 5.
fix
If using webpack 4, pin to version 2.x. Otherwise upgrade to webpack 5.
affects: >=3.0.0
Errors
Common errors & fixes
TypeError: CnameWebpackPlugin is not a constructor
Using ES6 import incorrectly on a CJS module.
fix
Use require('cname-webpack-plugin') instead of import.
Error: Cannot find module 'cname-webpack-plugin'
Missing package installation or incorrect path.
fix
Run 'npm install cname-webpack-plugin --save-dev' and ensure node_modules exists.
ValidationError: Invalid options object. Cname Webpack Plugin has been initialized using an options object that does not match the API schema.
Options object missing required 'domain' property.
fix
Pass an object with a 'domain' key: new CnameWebpackPlugin({ domain: 'example.com' });
Upgrade
Version history
3.0.0latest on npm
Audit
Dependencies
webpackrequiredpeer dependency required for plugin to work
Agent activity
2 hits · last 30 days
node
2
Resources
cname-webpack-plugin — npm install cname-webpack-plugin · libregistry