Registry / devops / csso-webpack-plugin

csso-webpack-plugin

JSON →
library3.0.0jsnpmunverified

Webpack plugin for CSSO minification that processes CSS bundles to reduce size. Current stable is v2.0.0-beta.3, with v3.0.0 published but ships CSSO 5.x (breaking). Releases are irregular. Differentiators: supports full restructuring across chunks, works with CSS Modules custom syntax, can output both pure and minified versions simultaneously via pluginOutputPostfix. Alternative to csso-loader or postcss-csso.

npm install csso-webpack-plugin
INSTALL
IMPORT
SIG · CSSO-WEBPACK-PLUGI
C
csso-webpack-plugin
devopsjavascriptv3.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

default
✓ import CssoWebpackPlugin from 'csso-webpack-plugin'
✗ const CssoWebpackPlugin = require('csso-webpack-plugin')
CommonJS require returns the plugin as the default export; use .default if using CJS with ES module interop.
CssoWebpackPlugin
✓ const CssoWebpackPlugin = require('csso-webpack-plugin').default
✗ const CssoWebpackPlugin = require('csso-webpack-plugin')
CommonJS require returns the module object, the plugin is on .default. In ESM, default import works directly.
CssoOptions
✓ import type { CssoOptions } from 'csso-webpack-plugin'
✗ import { CssoOptions } from 'csso-webpack-plugin'
CssoOptions is a TypeScript type/interface, not a runtime value.

Basic webpack config using MiniCssExtractPlugin and CssoWebpackPlugin to minify CSS output.

import CssoWebpackPlugin from 'csso-webpack-plugin'; import MiniCssExtractPlugin from 'mini-css-extract-plugin'; const config = { entry: './src/index.js', output: { filename: 'bundle.js' }, module: { rules: [ { test: /\.css$/, use: [MiniCssExtractPlugin.loader, 'css-loader'] } ] }, plugins: [ new MiniCssExtractPlugin({ filename: '[name].css' }), new CssoWebpackPlugin() ] }; export default config;
Debug
Known issues
breakingVersion 3.0.0 requires Node.js >=10 and CSSO 5.x, which may produce different output than CSSO 4.x.
fix
Use v2.x for Node <10 or CSSO 4.x compatibility.
affects: >=3.0.0
breakingIn v2.0.0, the plugin switched to async/await, dropping support for Node <8.
fix
Use v1.x for Node <8.
affects: >=2.0.0 <3.0.0
deprecatedoptions.sourceMap is deprecated since v1.0.0-beta.8; use webpack devtool instead.
fix
Remove sourceMap option and set devtool in webpack config.
affects: >=1.0.0-beta.8
gotchaWith CJS require, the plugin is on .default, not the returned object directly.
fix
Use require('csso-webpack-plugin').default or enable esModuleInterop.
affects: >=1.0.0
gotchaThe package ships Flow types in lib/index.js.flow but this may cause confusion for TypeScript users.
fix
Ignore .flow files; TypeScript types are bundled.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: CssoWebpackPlugin is not a constructor
Using CommonJS require without accessing .default export.
fix
Change to: const CssoWebpackPlugin = require('csso-webpack-plugin').default;
Error: Cannot find module 'csso-webpack-plugin'
Missing installation or wrong package name.
fix
Run: npm install --save-dev csso-webpack-plugin
Module parse failed: Unexpected token (1:0) You may need an appropriate loader to handle this file type.
CSS not processed by css-loader before plugin.
fix
Add a rule for .css files using css-loader and MiniCssExtractPlugin.loader.
Upgrade
Version history
3.0.0latest on npm
Audit
Dependencies
cssorequiredCSS minimizer engine
Agent activity
9 hits · last 30 days
node
8
Resources
csso-webpack-plugin — npm install csso-webpack-plugin · libregistry