Registry /
web-framework / postcss-assets-webpack-plugin
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
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
PostCSSAssetsPlugin
✓ import PostCSSAssetsPlugin from 'postcss-assets-webpack-plugin'
✗ const PostCSSAssetsPlugin = require('postcss-assets-webpack-plugin')
Package is ESM-only; using require will fail. Use import or dynamic import.
PostCSSAssetsPlugin
✓ // No type import; plugin is not typed
// Use @types/postcss-assets-webpack-plugin if available
✗ import type { PostCSSAssetsPlugin } from 'postcss-assets-webpack-plugin'
The package does not ship TypeScript declarations; community types may exist.
PostCSSAssetsPlugin
✓ const PostCSSAssetsPlugin = require('postcss-assets-webpack-plugin').default
✗ const PostCSSAssetsPlugin = require('postcss-assets-webpack-plugin')
In CommonJS, the default export is under .default; direct require returns a module object.
Configures Webpack to extract CSS with MiniCssExtractPlugin and then apply PostCSS plugins (mqpacker and csswring) to the bundled CSS using postcss-assets-webpack-plugin.
import webpack from 'webpack';
import csswring from 'csswring';
import mqpacker from 'mqpacker';
import autoprefixer from 'autoprefixer';
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
import PostCSSAssetsPlugin from 'postcss-assets-webpack-plugin';
const devMode = process.env.NODE_ENV !== 'production';
export default {
entry: './src/index.js',
module: {
rules: [
{
test: /\.css$/,
use: [
devMode ? 'style-loader' : MiniCssExtractPlugin.loader,
'css-loader',
'postcss-loader'
]
}
]
},
plugins: [
new MiniCssExtractPlugin({
filename: devMode ? '[name].css' : '[name].[contenthash].css'
}),
new PostCSSAssetsPlugin({
test: /\.css$/,
plugins: [
mqpacker(),
csswring({ preservehacks: true, removeallcomments: true })
],
log: !devMode
})
]
}
Errors
Common errors & fixes
TypeError: Cannot read property 'assets' of undefined
MiniCssExtractPlugin not used or not yet emitted assets when plugin runs.
fixEnsure MiniCssExtractPlugin is registered before PostCSSAssetsPlugin in the plugins array.
Error: PostCSS plugin returned undefined. Did you forget to return a function?
Plugin in the `plugins` array is not a valid PostCSS plugin (e.g., a string or invalid object).
fixCheck that all items in the `plugins` array are PostCSS plugin instances (e.g., require('mqpacker')() ). Module not found: Can't resolve 'postcss'
PostCSS is not installed as a dependency.
fixRun `npm install --save-dev postcss`.
Audit
Dependencies
webpackrequiredPeer dependency; required at runtime for plugin registration