{"id":24983664,"url":"https://github.com/posthtml/posthtml-postcss","last_synced_at":"2025-04-04T19:12:10.093Z","repository":{"id":37334641,"uuid":"46742167","full_name":"posthtml/posthtml-postcss","owner":"posthtml","description":"Use PostCSS with PostHTML.","archived":false,"fork":false,"pushed_at":"2024-10-07T22:14:08.000Z","size":842,"stargazers_count":49,"open_issues_count":6,"forks_count":15,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-29T21:06:06.905Z","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":".github/funding.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":"posthtml","open_collective":"posthtml","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2015-11-23T19:14:04.000Z","updated_at":"2024-09-19T17:16:50.000Z","dependencies_parsed_at":"2024-05-20T14:51:48.973Z","dependency_job_id":"214dfc7b-8cd3-4f96-9b75-d5c6456aae63","html_url":"https://github.com/posthtml/posthtml-postcss","commit_stats":{"total_commits":128,"total_committers":14,"mean_commits":9.142857142857142,"dds":0.75,"last_synced_commit":"1e863133ce5e709c18a7e68b8896cf1d7906fa4d"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-postcss","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-postcss/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-postcss/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-postcss/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/posthtml","download_url":"https://codeload.github.com/posthtml/posthtml-postcss/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247174858,"owners_count":20896154,"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:15.913Z","updated_at":"2025-04-04T19:12:10.074Z","avatar_url":"https://github.com/posthtml.png","language":"JavaScript","readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg width=\"150\" height=\"150\" alt=\"PostHTML\" src=\"https://posthtml.github.io/posthtml/logo.svg\"\u003e\n  \u003ch1\u003ePostCSS Plugin\u003c/h1\u003e\n  \u003cp\u003eUse \u003ca href=\"https://github.com/postcss/postcss/\"\u003ePostCSS\u003c/a\u003e with PostHTML\u003c/p\u003e\n\n  [![Version][npm-version-shield]][npm]\n  [![Build][github-ci-shield]][github-ci]\n  [![License][license-shield]][license]\n  [![Downloads][npm-stats-shield]][npm-stats]\n\u003c/div\u003e\n\n## Install\n\n```bash\nnpm i -D posthtml-postcss\n```\n\n## Usage\n\n```js\nimport {dirname} from 'node:path'\nimport {readFileSync} from 'node:fs'\nimport {fileURLToPath} from 'node:url'\n\nimport posthtml from 'posthtml'\nimport postcss from 'posthtml-postcss'\n\nconst postcssPlugins = []\nconst postcssOptions = {}\nconst filterType = /^text\\/css$/\n\nconst __filename = fileURLToPath(import.meta.url)\nconst __dirname = dirname(__filename)\n\nconst filePath = `${__dirname}/index.html`\nconst html = readFileSync(filePath, 'utf8')\n\nposthtml([ \n  postcss(postcssPlugins, postcssOptions, filterType) \n])\n  .process(html, {from: filePath})\n  .then((result) =\u003e console.log(result.html))\n```\n\nIf you don't pass any arguments to `posthtml-postcss`, it will try to use your project's PostCSS configuration (see [`postcss-load-config`](https://www.npmjs.com/package/postcss-load-config)).\n\nNotice that we're setting the option `from` when calling `process`. `posthtml-postcss` forwards this to PostCSS, which is useful for syntax error messages. (`postcss-cli` and `gulp-posthtml` are setting `from` automatically.)\n\n## Example\n\n```js\nimport posthtml from 'posthtml'\nimport postcss from 'posthtml-postcss'\nimport autoprefixer from 'autoprefixer'\n\nconst postcssPlugins = [\n  autoprefixer({ browsers: ['last 2 versions'] })\n]\nconst postcssOptions = {}\nconst filterType = /^text\\/css$/\n\nconst html = `\n  \u003cstyle\u003ediv { display: flex; }\u003c/style\u003e\n  \u003cdiv style=\"display: flex;\"\u003eText\u003c/div\u003e\n`\n\nposthtml([ \n  postcss(postcssPlugins, postcssOptions, filterType) \n])\n  .process(html)\n  .then(result =\u003e console.log(result.html))\n```\n\nOutput:\n\n```html\n\u003cstyle\u003e\n  div { display: -webkit-flex;display: -ms-flexbox;display: flex; }\n\u003c/style\u003e\n\u003cdiv style=\"display: -webkit-flex;display: -ms-flexbox;display: flex;\"\u003e\n  Text\n\u003c/div\u003e\n```\n\n[npm]: https://www.npmjs.com/package/posthtml-postcss\n[npm-version-shield]: https://img.shields.io/npm/v/posthtml-postcss.svg\n[npm-stats]: https://npm-stat.com/charts.html?package=posthtml-postcss\n[npm-stats-shield]: https://img.shields.io/npm/dt/posthtml-postcss.svg\n[github-ci]: https://github.com/posthtml/posthtml-postcss/actions/workflows/nodejs.yml\n[github-ci-shield]: https://github.com/posthtml/posthtml-postcss/actions/workflows/nodejs.yml/badge.svg\n[license]: ./LICENSE\n[license-shield]: https://img.shields.io/npm/l/posthtml-postcss.svg\n","funding_links":["https://patreon.com/posthtml","https://opencollective.com/posthtml"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposthtml%2Fposthtml-postcss","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fposthtml%2Fposthtml-postcss","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposthtml%2Fposthtml-postcss/lists"}