Gathering detailed insights and metrics for postcss-pipeline-webpack-plugin
Gathering detailed insights and metrics for postcss-pipeline-webpack-plugin
Gathering detailed insights and metrics for postcss-pipeline-webpack-plugin
Gathering detailed insights and metrics for postcss-pipeline-webpack-plugin
A webpack plugin to process generated assets with PostCSS pipeline
npm install postcss-pipeline-webpack-plugin
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
49 Stars
184 Commits
4 Forks
2 Watchers
1 Branches
4 Contributors
Updated on Nov 13, 2022
Latest Version
6.0.0
Package Id
postcss-pipeline-webpack-plugin@6.0.0
Unpacked Size
9.89 kB
Size
3.71 kB
File Count
4
NPM Version
6.14.5
Node Version
14.4.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
A webpack plugin to process generated assets with PostCSS pipeline.
Webpack loaders are pretty cool but limited to process and generate only one file at a time. If you are extracting critical CSS or media queries into separate files, you are no longer able to process these files. This plugin was made to solve this problem.
npm install --save postcss-pipeline-webpack-plugin
It requires webpack 5.x to work.
For webpack 4.x use postcss-pipeline-webpack-plugin@5 package.
For webpack 3.x use postcss-pipeline-webpack-plugin@3 package.
The plugin is compatible with PostCSS 6.x, 7.x and 8.x branches.
1const postcss = require('postcss'); 2const PostCssPipelineWebpackPlugin = require('postcss-pipeline-webpack-plugin'); 3 4const pipelinePlugin = new PostCssPipelineWebpackPlugin({ 5 processor: postcss([ 6 // provide any PostCSS plugins here 7 ]), 8 // provide an optional function to filter out unwanted CSS 9 predicate: name => /foobar.css$/.test(name), 10 // provide an optional string attached to the beginning of a new file 11 prefix: 'critical', 12 // provide an optional string which will be using as a suffix for newly generated files 13 suffix: 'processed', 14 // or you can generate the name by yourself 15 transformName: name => 'critical-' + name, 16 // you can pass any relevant SourceMap options 17 // see https://github.com/postcss/postcss/blob/master/docs/source-maps.md 18 map: {} 19});
So, you can use this initialized instance of the plugin in webpack configuration later.
1module.exports = { 2 mode: 'production', 3 4 entry: './src/index.css', 5 6 output: { 7 path: path.resolve('./dest/'), 8 filename: '[name].js' 9 }, 10 11 module: { 12 rules: [ 13 { 14 test: /\.css$/, 15 use: [ 16 MiniCssExtractPlugin.loader, 17 'css-loader' 18 ] 19 } 20 ] 21 }, 22 23 plugins: [ 24 new MiniCssExtractPlugin({ 25 filename: 'styles.css' 26 }), 27 pipelinePlugin 28 ] 29};
For example, you may want to process your styles with postcss-critical-css plugin. It generates an additional file, which contains only styles between start- and stop-tags. You can’t use the optimization of generated styles before the plugin because minification removes all comments. So, you have to minify “all” and “critical” parts separately.
It’s pretty easy with postcss-pipeline-webpack-plugin. You can provide as many PostCSS pipelines as you need.
For the task, we need to set up two pipelines with one plugin in each other:
1const PostCssPipelineWebpackPlugin = require('postcss-pipeline-webpack-plugin'); 2const MiniCssExtractPlugin = require('mini-css-extract-plugin'); 3const postcss = require('postcss'); 4const criticalSplit = require('postcss-critical-split'); 5const csso = require('postcss-csso'); 6 7module.exports = { 8 // ... 9 plugins: [ 10 new MiniCssExtractPlugin({ 11 filename: 'styles.css' 12 }), 13 new PostCssPipelineWebpackPlugin({ 14 suffix: 'critical', 15 processor: postcss([ 16 criticalSplit({ 17 output: criticalSplit.output_types.CRITICAL_CSS 18 }) 19 ]) 20 }), 21 new PostCssPipelineWebpackPlugin({ 22 suffix: 'min', 23 processor: postcss([ 24 csso({ 25 restructure: false 26 }) 27 ]), 28 map: { 29 inline: false 30 } 31 }) 32 ] 33};
1styles.css
styles.critical.css
. So, you get two files:1styles.css 2styles.critical.css
1styles.css 2styles.critical.css 3styles.min.css 4styles.min.css.map 5styles.critical.min.css 6styles.critical.min.css.map
As you can see, webpack generates artifacts in one pass.
See full webpack.config.js for more details.
2020-12-24
2019-08-02
2019-07-07
2019-07-03
transformName
option to generate destination filenames2019-03-09
pipeline
option was replaced with processor
to let the developer decide which version of the PostCSS to use2019-03-09
2019-03-05
DEPRECATED
2018-07-30
prefix
option2018-03-27
2018-02-05
[name].css?[contenthash]
2017-08-14
2017-05-30
2017-03-20
2016-12-28
2016-12-27
suffix
can contain any falsy value to skip rename2016-12-20
ISC
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/25 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
26 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More