1.0.2 • Published 10 years ago
postcss-unroot v1.0.2
UnRoot 
UnRoot replaces selectors containing :root with html. This can be useful for outputting CSS for older browsers like Internet Explorer 8.
/* before */
:root {
background-color: black;
color: white;
}
/* after */
html {
background-color: black;
color: white;
}Usage
Follow these steps to use UnRoot.
Add UnRoot to your build tool:
npm install postcss-unroot --save-devNode
require('postcss-unroot')({ /* options */ }).process(YOUR_CSS);PostCSS
Add PostCSS to your build tool:
npm install postcss --save-devLoad UnRoot as a PostCSS plugin:
postcss([
require('postcss-unroot')({ /* options */ })
]);Gulp
Add Gulp PostCSS to your build tool:
npm install gulp-postcss --save-devEnable UnRoot within your Gulpfile:
var postcss = require('gulp-postcss');
gulp.task('css', function () {
return gulp.src('./css/src/*.css').pipe(
postcss([
require('postcss-unroot')({ /* options */ })
])
).pipe(
gulp.dest('./css')
);
});Grunt
Add Grunt PostCSS to your build tool:
npm install grunt-postcss --save-devEnable UnRoot within your Gruntfile:
grunt.loadNpmTasks('grunt-postcss');
grunt.initConfig({
postcss: {
options: {
processors: [
require('postcss-unroot')({ /* options */ })
]
},
dist: {
src: 'css/*.css'
}
}
});Options
method
Type: String
Default: 'replace'
replace
Replace any selectors with :root with html.
/* before */
:root {
color: red;
}
/* after */
html {
color: red;
}copy
Copy any selectors with :root into a cloned rule as html.
/* before */
:root {
color: red;
}
/* after */
html {
color: red;
}
:root {
color: red;
}warn
Warn when a :root selector is used.