Automatically detects process (PostCSS or PostHTML) creates a configuration and loads the plugins.
Automatically detects the running environment on the basis of which creates the configuration for plugins using post-config used in the process and sorts the execution order of plugins using post-sequence.
post-config - Automatically detect all plugins installed and create a configuration for them from the description in package.json used in the process.
post-sequence - Generates the correct sequence of execution of plug-ins for the executable
Will inform you if the plugin has not been installed

$ npm install post-load-plugins Note: This project is compatible with node v4+
$ npm install postcss posthtml post-load-plugins - Install plugins for your processor
$ npm install autoprefixer postcss-at-rules-variables postcss-csso posthtml-bem posthtml-beautifyOptionalCreate configuration for plugins is different from the default in package.json.
For plugins not having configuration installed locally will be used default settings.
"postcss":{
"plugins": {
"autoprefixer": {
"browsers": ["last 2 versions"]
},
"at-rules-variables": {
"atRule": ["@media"]
}
}
},
"posthtml": {
"bem": {
"elemPrefix": "__",
"modPrefix": "--",
"modDlmtr": "-"
}
}Attention, it is recommended to use notation as above for postcss
postcss: { plugins: { ... } }, but both types are supported notationposthtml: { bem: { ... }, plugins: { beautify: { ... } } }.
The names of the plugins it is recommended to use no name of the processor as described above for postcss, but supported the full name of the plugin, the plugin name without the process in kebab
at-rules-variablesand camel caseatRulesVariables.
Nodejs with PostCSS
package.json
"name": "my-post-project",
"devDependencies": {
"autoprefixer": "^6.5.4",
"postcss": "^5.2.6",
"postcss-csso": "^1.1.2"
},
"postcss":{
"plugins": {
"autoprefixer": {
"browsers": ["last 2 versions"]
}
}
}index.js
import postcss from 'postcss';
import postLoadPlugins from 'post-load-plugins';
postcss(postLoadPlugins()).process('.test { display: flex; color: #ff0000;} @charset "utf-8";');
// result => .test{display:-ms-flexbox;display:flex;color:red}Will apply autoprefixer with option described in the configuration "browsers": ["last 2 versions"] and postcss-csso with default settings
--
Nodejs with PostHTML
package.json
"name": "my-post-project",
"devDependencies": {
"posthtml": "^0.9.0",
"posthtml-bem": "^0.2.2",
"posthtml-beautify": "0.1.0"
},
"posthtml": {
"bem": {
"elemPrefix": "__",
"modPrefix": "--",
"modDlmtr": "-"
}
}index.js
import posthtml from 'posthtml';
import postLoadPlugins from 'post-load-plugins';
const html = `
<div block="content">
<h1 elem="title">Title</h1>
<p elem="text" mods="red">Text</p>
</div>
`;
posthtml(postLoadPlugins()).process(html);
// result =>
// <div class="content">
// <h1 class="content__title">Title</h1>
//
// <p class="content__text content__text--red">Text</p>
// </div>Type: Array
Default: []
Description: May contain an Object with properties or path to config for the expansion
extend.config.json
"bem": {
"modPrefix": "---"
}Will automatically try to determine if you do not specify a process name in the package name or the package does not reside in the property matching process
index.js
import posthtml from 'posthtml';
import postLoadPlugins from 'post-load-plugins';
const html = `
<div block="content">
<h1 elem="title">Title</h1>
<p elem="text" mods="red">Text</p>
</div>
`;
posthtml(postLoadPlugins({extends: ['path/to/file/extend.config.json']})).process(html);
// result =>
// <div class="content">
// <h1 class="content__title">Title</h1>
//
// <p class="content__text content__text---red">Text</p>
// </div>Expand the current configuration for posthtml plugins bem
MIT License (MIT)
Copyright (c) Ivan Demidov scrum@list.ru
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.