Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@helpfulhuman/postcss-preset

Package Overview
Dependencies
Maintainers
7
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@helpfulhuman/postcss-preset

A tool for creating PostCSS configurations based on internal standards at Helpful Human.

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
7
Weekly downloads
 
Created
Source

Helpful Human's PostCSS Presets

This library provides a default set of PostCSS plugins and configurations based on the internal standards employed at Helpful Human.

Getting Started

Install via npm:

npm install --save-dev @helpfulhuman/postcss-preset

Usage

The buildConfig() method allows you to quickly create the entire config needed for PostCSS.

Standard PostCSS Config

If you're using PostCSS directly with postcss-cli command line tool, you can create a postcss.config.js file and export the results of the buildConfig() method. This approach is likely the best solution for adding PostCSS support to codebases where modern tools like Webpack are not available or not needed.

Note: The postcss-partial-import plugin is added when using the default buildMode. This means you can use @import with relative filepaths or globs to include files in your bundled file, like you would with SASS or Stylus.

var preset = require("@helpfulhuman/postcss-preset");

// no arguments are required
module.exports = preset.buildConfig({
  variables: {
    bodyFont: "Helvetica Neue, Arial, sans-serif",
    brandColor: "#CC3300",
  },
});

Now you can the postcss command line utility to build your CSS.

postcss src/index.css --map --output public/main.css

Plugins Only

Alternatively, if you're in a situation where you don't need a full configuration for PostCSS, you can get an array of just the configured plugins using the buildPlugins() method.

Note: buildConfig() invokes this function under the hood.

var preset = require("@helpfulhuman/postcss-preset");

var plugins = preset.buildPlugins({ /* options */ });

Options

NameTypeDescription
autoresetObjectEnables the autoreset plugin when a configuration object is provided, and the plugin is disabled when set to null. Recommended for use with CSS modules. Defaults to null.
browsersString[]An array of strings used for automatically adding vendor prefixes. See autoprefixer's browser documentation for more information. Defaults to ["last 2 version", "ie >= 10"]
enableShortRulesBoolEnables the use of short rule notation when set to true. Defaults to true.
legacyBrowsersBoolEnables broadstroke legacy browser support (like IE9) when set to true. Defaults to false.
buildModeEnumMust be set to a value of MODE_DEFAULT, MODE_MODULES or MODE_WEBPACK. Defaults to MODE_DEFAULT.
nextCSSBoolWhen true, enables polyfills for future CSS features including custom properties, var(), @apply, variable calc(), @custom-media, @media ranges, @custom-selector, element nesting, image-set, case-insensitive attributes, hwb(), Level-4 hsl() and rgb(), gray(), RGBA hexadecimal color notations, color(), system-ui fonts, font-variant, filter() (for SVGs), :matches, Level-4 :not, :any-link, and overflow-wrap. Defaults to true.
optimizeBoolOptimizes the final output for production releases. Defaults to true when the NODE_ENV is set to production.
preCSSString[]Enable various preprocessor features by providing an array of features to enable. Defaults to all options: ["@import", "@mixin", "@at-root", "@lookup", "@extend"].
pseudoFallbacksBoolProvides single colon fallbacks for ::pseudo elements including before, after, first-letter, first-line, first-child, last-child, hover, focus, and active in order to support older browsers when set to true. Defaults to legacyBrowsers' value.
remFallbackBoolHelps support older browsers by automatically adding a px fallback for rules using rem units. Defaults to legacyBrowsers' value.
rgbaFallbackBoolEnables rgba() to rgb() fallback to be added for legacy browsers when set to true. Defaults to legacyBrowsers' value.
variablesObjectProvide an object literal of variables to be injected and made globally available in your stylesheets.

$sudo Options

Warning: It is recommended that you don't touch these unless absolutely necessary.

Not listed in the options table above is the $sudo field that allows you to manually provide configurations to each individual plugin used by this library. Along with the standard options that each plugin supports individually, a forceEnable feature is also available to ensure that the plugin is included with your configuration (despite the settings above).

Example
var preset = require("@helpfulhuman/postcss-preset");

module.exports = preset.buildConfig({
  $sudo: {
    autoreset: {
      reset: {
        margin: 0,
        padding: 0,
        borderRadius: 0,
      },
    },
    customProperties: {
      preserve: true,
    },
  },
});

Below is a list of all of the plugins you can configure and their corresponding key name.

KeyPlugin
partialImportpostcss-partial-import
advancedVarspostcss-advanced-variables
autoresetpostcss-autoreset
shortpostcss-short
customPropspostcss-custom-properties
applypostcss-apply
calcpostcss-calc
customMediapostcss-custom-media
mediaMinMaxpostcss-media-minmax
customSelectorspostcss-custom-selectors
nestingpostcss-nesting
imageSetpostcss-image-set-polyfill
attributeCaseInsensitivepostcss-attribute-case-insensitive
colorHwbpostcss-color-hwb
colorHslpostcss-color-hsl
colorRgbpostcss-color-rgb
colorGraypostcss-color-gray
colorHexAlphapostcss-color-hex-alpha
colorFunctionpostcss-color-function
fontFamilySystemUipostcss-font-family-system-ui
fontVariantpostcss-font-variant
filterspleeease-filters
initialpostcss-initial
pseudoElementspostcss-pseudoelements
selectorMatchespostcss-selector-matches
selectorNotpostcss-selector-not
pseudoClassAnyLinkpostcss-pseudo-class-any-link
replaceOverflowWrappostcss-replace-overflow-wrap
colorRgbaFallbackpostcss-color-rgba-fallback
pixrempixrem
autoprefixerautoprefixer
cssnanocssnano

Keywords

FAQs

Package last updated on 03 Sep 2017

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