{"id":24983671,"url":"https://github.com/posthtml/posthtml-load-plugins","last_synced_at":"2025-07-10T18:34:38.203Z","repository":{"id":57328819,"uuid":"51703048","full_name":"posthtml/posthtml-load-plugins","owner":"posthtml","description":"Autoload Plugins for PostHTML","archived":false,"fork":false,"pushed_at":"2016-11-23T08:17:44.000Z","size":72,"stargazers_count":3,"open_issues_count":7,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-01T18:10:12.128Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/posthtml.png","metadata":{"files":{"readme":"readme.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-14T16:45:11.000Z","updated_at":"2017-01-21T22:02:13.000Z","dependencies_parsed_at":"2022-09-13T23:11:58.549Z","dependency_job_id":null,"html_url":"https://github.com/posthtml/posthtml-load-plugins","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/posthtml/posthtml-load-plugins","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-load-plugins","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-load-plugins/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-load-plugins/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-load-plugins/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/posthtml","download_url":"https://codeload.github.com/posthtml/posthtml-load-plugins/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-load-plugins/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264618128,"owners_count":23638221,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-04T09:20:16.296Z","updated_at":"2025-07-10T18:34:38.185Z","avatar_url":"https://github.com/posthtml.png","language":"JavaScript","readme":"[![npm version][npm]][npm-url]\n[![Dependencies][deps]][deps-url]\n[![Build Status][travis-image]][travis-url]\n[![Coverage Status][cover-image]][cover-url]\n[![XO Code Style][style]][style-url]\n\n# Autoload Plugins for [PostHTML](https://github.com/posthtml/posthtml)\n\n## Install\n\n```bash\n(sudo) npm i -D posthtml-load-plugins\n```\n## Usage\n\nPlugins will be loaded directly from your projects ***package.json*** file or local installed plugins.  \nInstall them as usual with ``` npm i -S ``` or ``` npm i -D ``` or ```npm i```.\n\n[PostHTML Plugins](https://maltsev.github.io/posthtml-plugins/)\n\nAfter installing your plugins there a three ways to declare your plugin options.\n\n- Set options directly as arguments.\n- Set options in your ***package.json***.\n- Create a separated ***[name].[ext]*** file, where ***[name]*** is any name you like and ***[ext]*** should be either ``` .js ``` or ``` .json ```.\nFor an example of well formed options file see below.\n- For plugins not having rules installed locally will be used default settings.\n- Pretty reporting about not installed plugins.\n\n![](reporting.jpg)\n\n## Options\n\n### package.json\n\n```json\n{\n    \"dependencies\": {\n        \"posthtml-bem\": \"^0.2.2\",\n        \"posthtml-each\": \"^1.0.1\",\n        \"posthtml-include\": \"^1.0.2\"\n},\n    \"devDependencies\": {\n        \"posthtml-style-to-file\": \"^0.1.1\"\n},\n    \"posthtml\": {\n        \"bem\": {\n            \"elemPrefix\": \"__\",\n            \"modPrefix\": \"-\",\n            \"modDlmtr\": \"--\"\n        },\n        \"include\": {\n            \"root\": \"./\",\n            \"encoding\": \"utf-8\"\n        },\n        \"styleToFile\": {\n            \"path\": \"./dist/style.css\"\n        }\n    }\n}\n```\n\n### [name].[ext]\n\n#### JS\n```js\nmodule.exports = {\n    bem: {\n        elemPrefix: '__',\n        modPrefix: '-',\n        modDlmtr: '--'\n    },\n    include: {\n        root: './',\n        encoding: 'utf-8'\n    },\n    styleToFile: {\n        path: './dist/style.css'\n    }\n}\n```\nor\n\n```js\nmodule.exports = [\n    {\n        bem: {\n            elemPrefix: '__',\n            modPrefix: '-',\n            modDlmtr: '--'\n        },\n        include: {\n            root: './',\n            encoding: 'utf-8'\n        }\n    }, {\n        styleToFile: {\n            path: './dist/style.css'\n        }\n    }\n]\n```\n#### JSON\n\n```json\n{\n    \"bem\": {\n        \"elemPrefix\": \"__\",\n        \"modPrefix\": \"-\",\n        \"modDlmtr\": \"--\"\n    },\n    \"include\": {\n        \"root\": \"./\",\n        \"encoding\": \"utf-8\"\n    },\n    \"styleToFile\": {\n        \"path\": \"./dist/style.css\"\n    }\n}\n```\n\n## Usage\nFor general usage and build process integration see [PostHTML Docs](https://github.com/posthtml/posthtml#usage)\n\n### Examples using Node API\n#### Default\n\n```js\nconst fs = require('fs');\n\nconst posthtml = require('posthtml');\nconst plugins = require('posthtml-load-plugins');\n\nlet html = fs.readFileSync('./index.html', 'utf8');\n\nposthtml(plugins([object|array[objects]|file] /* options */, [object|array[objects]|file] /* extends */))\n    .process(html)\n    .then(result =\u003e console.log(result.html));\n```\n\n\n#### Options file (e.g posthtml.json)\n\n```js\nconst fs = require('fs');\n\nconst posthtml = require('posthtml');\nconst plugins = require('posthtml-load-plugins')('posthtml.(js|json)');\n\nlet html = fs.readFileSync('./index.html', 'utf8');\n\nposthtml(plugins)\n    .process(html)\n    .then(result =\u003e console.log(result.html));\n```\n\n\n#### Extends options\n\n```js\nconst fs = require('fs');\n\nconst posthtml = require('posthtml');\nconst plugins = require('posthtml-load-plugins')('posthtml.(js|json)', {\"posthtml-bem\": {elemPrefix: '__'}});\n\nlet html = fs.readFileSync('./index.html', 'utf8');\n\nposthtml(plugins)\n    .process(html)\n    .then(result =\u003e console.log(result.html));\n```\n\n\n#### Use with [posthtml-standard-config](https://github.com/StandardHTML/posthtml-standard-config)\n\n```js\nconst fs = require('fs');\n\nconst posthtml = require('posthtml');\nconst standardConfig = require('posthtml-standard-config');\nconst plugins = require('posthtml-load-plugins')(standardConfig);\n\nlet html = fs.readFileSync('./index.html', 'utf8');\n\nposthtml(plugins)\n    .process(html)\n    .then(result =\u003e console.log(result.html));\n```\n\n## Contributors\n\n[![GitScrum](https://avatars.githubusercontent.com/u/2789192?s=130)](https://github.com/GitScrum) |\n---|\n[Ivan Demidov](https://github.com/GitScrum) |\n\n## License\n\nMIT\n\n[npm]:  https://img.shields.io/npm/v/posthtml-load-plugins.svg\n[npm-url]: https://www.npmjs.com/package/posthtml-load-plugins\n\n[deps]: https://david-dm.org/posthtml/posthtml-load-plugins.svg\n[deps-url]: https://david-dm.org/posthtml/posthtml-load-plugins\n\n[style]: https://img.shields.io/badge/code_style-XO-5ed9c7.svg\n[style-url]: https://github.com/posthtml/posthtml-load-plugins\n\n[travis-url]: https://travis-ci.org/posthtml/posthtml-load-plugins\n[travis-image]: http://img.shields.io/travis/posthtml/posthtml-load-plugins.svg\n\n[cover-image]:https://coveralls.io/repos/github/posthtml/posthtml-load-plugins/badge.svg?branch=master\n[cover-url]:https://coveralls.io/github/posthtml/posthtml-load-plugins?branch=master\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposthtml%2Fposthtml-load-plugins","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fposthtml%2Fposthtml-load-plugins","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposthtml%2Fposthtml-load-plugins/lists"}