Skip to content

Protect nodes inside @raw at-rules from being touched by other plugins.

Notifications You must be signed in to change notification settings

MadLittleMods/postcss-raw

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npm version Build Status

PostCSS Raw

PostCSS plugin to output nodes inside the @raw at-rule, untouched by other plugins in the plugin stack.

Install

npm install postcss-raw --save-dev

Usage

postcss-raw is a two-part process. First we inspect(require('postcss-raw').inspect()) and record any child nodes in the @raw at-rule and remove them from the AST tree. This way other plugins can't touch what was inside. Then when you run the write(require('postcss-raw').write()), we put those child nodes back in place without the wrapping @raw at-rule.

Basic Example

var postcss = require('postcss');
var raw = require('postcss-raw');
// ES6 modules:
//import { inspect as rawInspect, write as rawWrite } from 'postcss-raw';

var fs = require('fs');

var mycss = fs.readFileSync('input.css', 'utf8');

// Process your CSS with postcss-reverse-media
var output = postcss([
		raw.inspect(/*options*/),
		// other plugins...
		raw.write(/*options*/)
	])
	.process(mycss)
	.css;

console.log(output);

Input:

@raw {
	@import "variables";
	$foo: #f00;
}

Output:

@import "variables";
$foo: #f00;

Options

  • atRuleKeyword: string - The media query name keyword that applies the plugin.
    • Default: 'raw'

Testing

npm test

About

Protect nodes inside @raw at-rules from being touched by other plugins.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published