🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

postcss-replace

Package Overview
Dependencies
Maintainers
3
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-replace

PostCSS plugin for replacing strings.

latest
Source
npmnpm
Version
2.0.1
Version published
Weekly downloads
20K
-11.8%
Maintainers
3
Weekly downloads
 
Created
Source

PostCSS Replace PostCSS

NPM Version Build Status Coverage Status Licensing Changelog

PostCSS plugin for replacing strings.

Write this:

/* CustomCSS Library v{{ version }} */
.foo {
  content: "{{ author }}";
}

And get this:

/* CustomCSS Library v1.3.7 */
.foo {
  content: "Gridonic";
}

Installation

$ npm install postcss-replace

Usage

postcss([ require('postcss-replace') ])

See PostCSS docs for examples regarding usage.

Options

pattern

  • Type: string | RegEx
  • Default: '{{\\s?([^\\s]+?)\\s?}}'

The default pattern will replace strings in the format of {{ myExampleKey }}. Adjust this pattern if you want something different, for example /_([^\s]+?)_/ to match strings like _myExampleKey_.

commentsOnly

  • Type: boolean
  • Default: false

By default the plugin will replace strings in comments and values. Turn this to true if you only want to replace strings in comments.

data

  • Type: object
  • Default: {}

This is the key → value object that provides the data for the plugin for replacing strings.

  • If the key replaceAll is provided all matched strings will be replaced by the given value e.g: data: { replaceAll: 'replace all matched strings with this text' }

Testing

Tests can be run via the following command:

$ npm run test

We use mutant-testing to test the resilience of our tests. Stryker can be run via the following command:

$ npm run test:mutate

Keywords

postcss

FAQs

Package last updated on 21 Mar 2023

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