# postcss-only-one-root

> Removes all but one instance of :root

Latest version **1.0.1** (published 2018-06-20) · ISC license · 0 weekly downloads

## Install

```sh
npm install postcss-only-one-root
pnpm add postcss-only-one-root
yarn add postcss-only-one-root
bun add postcss-only-one-root
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2018-06-20 |
| First published | 2018-06-20 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 2.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Shannon Hochkins |
| Maintainers | shannonhochkins |
| Keywords | postcss, root, remove, all, but, one, duplicate |

## Links

- npm: https://www.npmjs.com/package/postcss-only-one-root
- Repository: https://github.com/shannonhochkins/postcss-only-one-root
- Homepage: https://github.com/shannonhochkins/postcss-only-one-root#readme
- Issues: https://github.com/shannonhochkins/postcss-only-one-root/issues
- npm.io page: https://npm.io/package/postcss-only-one-root

## Alternatives

- [style-dictionary](https://npm.io/package/style-dictionary.md) — 2.0M weekly downloads
- [postcss-merge-idents](https://npm.io/package/postcss-merge-idents.md) — 1.7M weekly downloads
- [@fontsource/noto-sans](https://npm.io/package/@fontsource/noto-sans.md) — 93.0K weekly downloads
- [uglifycss](https://npm.io/package/uglifycss.md) — 71.6K weekly downloads
- [mat4-interpolate](https://npm.io/package/mat4-interpolate.md) — 23.3K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2018-06-20
- 1.0.0 — 2018-06-20

## README

[![npm version](https://badge.fury.io/js/postcss-only-one-root.svg)](https://badge.fury.io/js/postcss-only-one-root)
[![npm](https://img.shields.io/npm/dt/postcss-only-one-root.svg)]()
# Postcss only one :root
> A [PostCSS](https://github.com/postcss/postcss) plugin to remove all instances of “:root”  but one from a stylesheet.

This plugin is very basic. It removes all instances of `:root` except for the first it encounters from a processed stylesheet (if present). I built this as I used automatical localised imports for my Webpack scss files, which occured in duplicate references to the :root selector variables.

Otherwise, you probably have no use for this plugin. You should run this plugin after running [postcss-custom-properties]

## Installation

```
npm install --save postcss-only-one-root
```

## Example

### variables.scss

```css
:root {
    --color-blue: blue;
}
```
### file.a.scss

```css
@import "./variables";
.something-1 {
    color: var(--color-blue);
}
```

### file.b.scss

```css
@import "./variables";
.something-2 {
    color: var(--color-blue);
}
```

### Output

```css
:root {
    color-blue: blue
}
.something-1 {
    color: blue;
    color: var(--color-blue);
}
.something-2 {
    color:blue;
    color: var(--color-blue);
}
```

## Usage

See the [PostCSS documentation](https://github.com/postcss/postcss#usage) for examples on how to use this plugin in different environments.
This plugin takes no options.

## [Changelog](CHANGELOG.md)

---
_Source: https://npm.io/package/postcss-only-one-root · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
