Registry / devops / add-charset-webpack-plugin

add-charset-webpack-plugin

JSON →
library1.0.9jsnpmunverified

A Webpack and Rspack plugin that automatically prepends a @charset declaration to every emitted CSS file. Version 1.0.9 is the latest stable release with no active development cadence. It supports both CommonJS and ES modules, works with Webpack 4/5 and Rspack. Unlike manual CSS header additions or postcss plugins, it hooks into the compilation process to guarantee charset placement on all CSS assets with zero configuration overhead.

npm install add-charset-webpack-plugin
INSTALL
IMPORT
SIG · ADD-CHARSET-WEBPAC
A
add-charset-webpack-plugin
devopsjavascriptv1.0.9
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.

AddCharsetWebpackPlugin
import AddCharsetWebpackPlugin from 'add-charset-webpack-plugin'
const { AddCharsetWebpackPlugin } = require('add-charset-webpack-plugin')
The package exports a default class; named destructuring with require will fail.
AddCharsetWebpackPlugin
const AddCharsetWebpackPlugin = require('add-charset-webpack-plugin')
const AddCharsetWebpackPlugin = require('add-charset-webpack-plugin').default
CommonJS require returns the class directly, not a module with a default property.
AddCharsetWebpackPlugin
import AddCharsetWebpackPlugin from 'add-charset-webpack-plugin'
import { AddCharsetWebpackPlugin } from 'add-charset-webpack-plugin'
Named import is incorrect; the plugin is the default export.

Demonstrates configuring the plugin with CommonJS require, setting charset to utf-8.

// webpack.config.js or rspack.config.js const AddCharsetWebpackPlugin = require('add-charset-webpack-plugin'); module.exports = { plugins: [ new AddCharsetWebpackPlugin({ charset: 'utf-8' }) ] };
Debug
Known issues
gotchaPlugin does not add charset to CSS imported via JavaScript (e.g., import './styles.css'). The @charset only applies to emitted CSS chunks, not inline styles.
fix
Ensure CSS files are emitted as separate files via MiniCssExtractPlugin or similar.
affects: >=1.0.0
gotchaIf charset option is set to a value that is not a valid CSS charset string (e.g., missing quotes), the plugin will add it verbatim, potentially breaking CSS validity.
fix
Always pass a quoted string like 'utf-8' or 'ISO-8859-1'.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: AddCharsetWebpackPlugin is not a constructor
Using named import { AddCharsetWebpackPlugin } from 'add-charset-webpack-plugin'
fix
Change to default import: import AddCharsetWebpackPlugin from 'add-charset-webpack-plugin'
Module not found: Error: Can't resolve 'add-charset-webpack-plugin'
Package not installed or typo in package name
fix
Run: npm install add-charset-webpack-plugin
Upgrade
Version history
1.0.9latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
53 hits · last 30 days
node
46
OpenAI (training)
1
Resources
add-charset-webpack-plugin — npm install add-charset-webpack-plugin · libregistry