Registry / web-framework / csso-loader

csso-loader

JSON →
library0.3.1jsnpmunverified

Webpack loader for CSS minification using CSSO. Current stable version is 0.3.1, with basic support for CSSO's restructure, comments, debug, and usage options. This loader allows inline query parameters or a top-level 'csso' config object. It works with webpack 1.x (loaders array) and has limited updates since last release; modern webpack versions may require a different loader syntax. It integrates after css-loader to minify CSS output.

npm install csso-loader
INSTALL
IMPORT
SIG · CSSO-LOADER
C
csso-loader
web-frameworkjavascriptv0.3.1
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
module.exports = { module: { loaders: [ { test: /\.css$/, loader: 'css-loader!csso-loader' } ] } }
import { csso-loader } from 'csso-loader'
The loader is used via webpack configuration, not imported directly in code. It must be chained after css-loader to minify CSS output.
csso
new webpack.LoaderOptionsPlugin({ options: { csso: { restructure: false } } })
import csso from 'csso-loader'
Options are passed via the 'csso' object in webpack config, not by importing the loader directly. Use LoaderOptionsPlugin for webpack 2+.
query parameters
loader: 'css-loader!csso-loader?-restructure&comments=false'
loader: 'csso-loader?restructure=false'
Query parameters use a minus sign to disable default options (e.g., -restructure). Boolean false requires the '?' prefix for disabled features.

Minimal webpack config using csso-loader after css-loader to minify CSS files.

// webpack.config.js module.exports = { entry: './index.js', output: { filename: 'bundle.js' }, module: { loaders: [ { test: /\.css$/, loader: 'css-loader!csso-loader', } ] } };
Debug
Known issues
deprecatedThis package uses webpack 1.x loader syntax. webpack 2+ uses rules.use or LoaderOptionsPlugin.
fix
For webpack 2+, replace 'loaders' with 'rules' and use 'loaderOptionsPlugin' to pass options or switch to style-loader / css-loader built-in minification.
affects: >=0.1.0
gotchaOptions in webpack config must be placed in top-level 'csso' object, not inside loader options.
fix
Either use query parameters in the loader string, or add 'csso' as a top-level key in webpack config.
affects: >=0.1.0
gotchaLoader chain order: css-loader must come before csso-loader (rightmost in loader string).
fix
Always use 'css-loader!csso-loader' in loader string so csso-loader receives already-parsed CSS.
affects: >=0.1.0
breakingCSSo 4.0+ dropped some options, but csso-loader pins to older csso version.
fix
Pin csso version to 3.x or migrate to a modern minifier like css-minimizer-webpack-plugin.
affects: >=0.3.0
Errors
Common errors & fixes
Module build failed: Error: No handler for content type 'text/css'
csso-loader receives non-CSS content, e.g., from css-loader output with modules enabled.
fix
Disable CSS modules for the rule targeted by csso-loader, or use a different minifier.
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
Using webpack 2+ and placing options in 'csso' object without LoaderOptionsPlugin.
fix
Wrap csso options in new webpack.LoaderOptionsPlugin({ options: { csso: { restructure: false } } }) and apply to the correct loaders.
Error: Cannot find module 'csso'
csso not installed or not in node_modules.
fix
Install csso as a devDependency: npm install csso --save-dev
Upgrade
Version history
0.3.1latest on npm
Audit
Dependencies
cssorequiredpeer dependency for CSSO minification
webpackrequiredruntime peer dependency for loader context
Agent activity
2 hits · last 30 days
node
2
Resources
csso-loader — npm install csso-loader · libregistry