Socket
Socket
Sign inDemoInstall

postcss-load-plugins

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-load-plugins

Autoload Plugins for PostCSS


Version published
Weekly downloads
189K
increased by5.7%
Maintainers
1
Weekly downloads
 
Created
Source

NPM Deps Tests Coverage Standard Code Style

Load Plugins

Autoload Plugins for PostCSS

Install

npm i -D postcss-load-plugins

Usage

Install plugin as usual and make sure saving them to your package.json dependencies and/or devDependencies.

npm i -S postcss-plugin
npm i -D postcss-plugin

After installing your plugins there a two common ways to declare your plugins and options.

  • Create postcss section in your projects package.json.
  • Create a postcss.config.js or postcssrc.json file.

Options

Plugin options can either take false or an object literal {} as value.

false : Plugin loads with no options (defaults)

[Object] : Plugin loads with set options.

Order

Plugin order is determined by declaration in the plugins section.

postcss: {
  plugins: {
    'postcss-plugin1': false,
    'postcss-plugin2': false,
    'postcss-plugin3': {}
  }
}

// Loaded Plugin Setup

[
  require('postcss-plugin1')(),
  require('postcss-plugin2')(),
  require('postcss-plugin3')(options)
]

Examples

package.json

{
 "dependencies": {
   "postcss-bem": "^0.2.2",
   "postcss-nested": "^1.0.0",
   "postcss-import": "^8.1.2"
 },
 "postcss": {
   "plugins": {
     "postcss-import": false,
     "postcss-nested": false,
     "postcss-bem": {
       "style": "bem",
       "separators": {
         "namespace": "-",
         "descendent":"__",
         "modifier": "--"
       }
      }  
    }
  }
}

postcss.config.js

module.exports = {
  plugins: {
    'postcss-import': false,
    'postcss-nested': false,
    'postcss-bem': {
      style: 'bem',
      separators: {
        namespace: '-',
        descendent: '__',
        modifier: '--'
      }
    }
  }
}
postcssrc.json
{
  "plugins": {
    "postcss-import": false,
    "postcss-nested": false,
    "postcss-bem": {
      "style": "bem",
      "separators": {
        "namespace": "-",
        "descendent":"__",
        "modifier": "--"
      }
    }
  }
}
const { readFileSync } = require('fs')

const postcss = require('postcss')
const pluginsrc = require('postcss-load-plugins')()

const css = readFileSync('./index.css', 'utf8')

pluginsrc.then((plugins) => {
  postcss(plugins)
    .process(css)
    .then(result => console.log(result.css))
}))

LICENSE

License (MIT)

Copyright (c) 2016 Michael Ciniawsky michael.ciniawsky@gmail.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Keywords

FAQs

Package last updated on 07 Jul 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc