Installations
npm install postcss-load-plugins
Developer
michael-ciniawsky
Developer Guide
Module System
CommonJS
Min. Node Version
>=0.12
Typescript Support
No
Node Version
7.5.0
NPM Version
4.1.2
Statistics
20 Stars
151 Commits
6 Forks
2 Watching
1 Branches
5 Contributors
Updated on 16 Jun 2020
Languages
JavaScript (86.15%)
CSS (13.85%)
Total Downloads
Cumulative downloads
Total Downloads
251,570,337
Last day
-12.8%
49,794
Compared to previous day
Last week
1.1%
287,057
Compared to previous week
Last month
31.3%
1,134,316
Compared to previous month
Last year
-14.9%
10,479,043
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Install
1npm i -D postcss-load-plugins
Usage
npm i -S|-D postcss-plugin
Install plugins and save them to your package.json dependencies/devDependencies.
package.json
Create postcss
section in your projects package.json
.
App
|– client
|– public
|
|- package.json
1{ 2 "postcss": { 3 "plugins": { 4 "postcss-plugin": {} 5 } 6 } 7}
.postcssrc
Create a .postcssrc
file.
App
|– client
|– public
|
|- (.postcssrc|.postcssrc.json|.postcssrc.yaml)
|- package.json
JSON
1{ 2 "plugins": { 3 "postcss-plugin": {} 4 } 5}
YAML
1plugins: 2 postcss-plugin: {}
postcss.config.js
or .postcssrc.js
You may need some JavaScript logic to generate your config. For this case you can use a file named postcss.config.js
or .postcssrc.js
.
App
|– client
|– public
|
|- (postcss.config.js|.postcssrc.js)
|- package.json
Plugins can be loaded in either using an {Object}
or an {Array}
.
{Object}
1module.exports = (ctx) => ({ 2 plugins: { 3 'postcss-plugin': ctx.plugin 4 } 5})
{Array}
1module.exports = (ctx) => ({ 2 plugins: [ 3 require('postcss-plugin')(ctx.plugin) 4 ] 5})
Options
Plugin options can take the following values.
{}
: Plugin loads with defaults
1'postcss-plugin': {} || null
:warning:
{}
must be an empty object
{Object}
: Plugin loads with options
1'postcss-plugin': { option: '', option: '' }
false
: Plugin will not be loaded
1'postcss-plugin': false
Order
Plugin order is determined by declaration in the plugins section.
1{ 2 plugins: { 3 'postcss-plugin': {}, // plugins[0] 4 'postcss-plugin': {}, // plugins[1] 5 'postcss-plugin': {} // plugins[2] 6 } 7}
Context
When using a function (postcss.config.js)
, it is possible to pass context to postcss-load-plugins
, which will be evaluated before loading your plugins. By default ctx.env (process.env.NODE_ENV)
and ctx.cwd (process.cwd())
are available.
Examples
postcss.config.js
1module.exports = (ctx) => ({ 2 plugins: { 3 postcss-import: {}, 4 postcss-modules: ctx.modules ? {} : false, 5 cssnano: ctx.env === 'production' ? {} : false 6 } 7})
1const { readFileSync } = require('fs') 2 3const postcss = require('postcss') 4const pluginsrc = require('postcss-load-plugins') 5 6const css = readFileSync('index.css', 'utf8') 7 8const ctx = { modules: true } 9 10pluginsrc(ctx).then((plugins) => { 11 postcss(plugins) 12 .process(css) 13 .then((result) => console.log(result.css)) 14})
Maintainers
Michael Ciniawsky |
Mateusz Derks |
Contributors
Diogo Franco |
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Warn: project license file does not contain an FSF or OSI license.
Reason
security policy file detected
Details
- Info: security policy file detected: github.com/michael-ciniawsky/.github/SECURITY.md:1
- Warn: no linked content found
- Warn: One or no descriptive hints of disclosure, vulnerability, and/or timelines in security policy
- Info: Found text in security policy: github.com/michael-ciniawsky/.github/SECURITY.md:1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/4 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 26 are checked with a SAST tool
Score
3.3
/10
Last Scanned on 2024-11-18
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