Package Exports
- post-config
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (post-config) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
post-config
Creates a configuration
Why?
For use in processors such as posthtml, postcss, reshape or for plug-ins. Automatically finds all the modules and tries to match them with the executable processes.
Install
$ npm install post-config
Note: This project is compatible with node v4+
Example
package.json
"name": "my-post-project",
"devDependencies": {
"posthtml": "^6.5.4",
"posthtml-spaceless": "^6.5.4",
"posthtml-custom-elements": "^5.2.6"
},
"posthtml":{
"sync": false,
"posthtml-custom-elements": {
"defaultTag": "span"
}
}
index.js
import posthtml from 'posthtml';
import postConfig from 'post-config';
const options = postConfig({namespace: ['posthtml']});
/*
Return configuration object for posthtml processor.
{
sync: false,
plugins: [
'posthtml-spaceless',
['posthtml-custom-elements', {
defaultTag: 'article'
}]
]
}
*/
const plugins = options.plugins.map(module => {
let config = {};
if (Array.isArray(module)) {
[module, config] = module;
}
return require(module)(config);
});
const html = `
<component>
<h1>Super Title</h1>
<text tag="p">Awesome Text</text>
<spaceless>
<ul>
<li class="box-inline col-6">Link</li>
<li class="box-inline col-6">Link</li>
</ul>
</spaceless>
</component>
`;
posthtml(plugins)
.process(html, options)
.then(result => console.log(result.html));
/*
Return result
<article class="component">
<h1>Super Title</h1>
<p>Awesome Text</p>
<ul><li class="box-inline col-6">Link</li><li class="box-inline col-6">Link</li></ul>
</article>
*/
Options
root
Type: String
Default: "./"
Description: Directory to find package.json
nodeModules
Type: String|Boolean
Default: node_modules
Description: Directory to find modules relatively root
dirictory. Set falsely is not necessary to look for modules in node_modules
namespace
Type: Array
Default: []
Description: Makes a search and a resulting configuration object for specified namespaces
extends
Type: Object
Default: {}
Description: Can extend configurations
config
Type: Object
Default: {}
Description: Inherits, supplements, and extends the resulting configuration object
namespace
Type: Array|String
Default: []
Description: Expands the list of namespace for better matching of modules
modules
Type: Array
Default: []
Description: Inherits, supplements, and extends the resulting configuration object
whitelist
Type: Object
Default: white-list.js
Description: Expands the list of module to namespace relationships
blacklist
Type: Array
Default: black-list.js
Description: Modules necessary to ignore when building the final configuration object