A PostCSS plugin that is used to wrap css styles with a css selector to constrain their affect on parent elements in a page.
Dependencies
Contributors
Getting Started
0. Ensure all Dependencies have been resolved.
1. Install the Node module:
npm install --save-dev postcss-prefixwrap
2. Load the module in your build configuration:
var prefixwrap = require("postcss-prefixwrap");
3. Instantiate the PostCSS plugin:
var wrapSelector = ".my-custom-wrap";
{
postcss: [
prefixwrap(wrapSelector)
]
}
4. Add the container to your markup:
<div class="my-custom-wrap">
</div>
5. Your css will now be contained:
p {
color: red;
}
body {
font-size: 16px;
}
.my-custom-wrap p {
color: red;
}
.my-custom-wrap {
font-size: 16px;
}
Testing
See https://travis-ci.org/dbtedman/postcss-prefixwrap for CI results, run on each commit.
Static Analysis
Code is linted using ESLint:
npm run test:lint
Unit Tests
Code is unit tested using MochaJS.
npm run test:unit
Releasing
Based on the NPM Publishing Guide, after updating the current version, run the following command:
npm publish