{"id":16716310,"url":"https://github.com/gucong3000/postcss-syntax","last_synced_at":"2025-04-06T07:14:11.975Z","repository":{"id":57328562,"uuid":"128884746","full_name":"gucong3000/postcss-syntax","owner":"gucong3000","description":"Automatically switch PostCSS syntax based on file extensions","archived":false,"fork":false,"pushed_at":"2020-10-23T23:50:43.000Z","size":129,"stargazers_count":45,"open_issues_count":3,"forks_count":7,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-30T06:07:09.858Z","etag":null,"topics":["css","extension","postcss","postcss-syntax","switch","syntax"],"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/gucong3000.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2018-04-10T06:30:36.000Z","updated_at":"2024-06-25T02:49:12.000Z","dependencies_parsed_at":"2022-09-21T01:52:21.592Z","dependency_job_id":null,"html_url":"https://github.com/gucong3000/postcss-syntax","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gucong3000%2Fpostcss-syntax","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gucong3000%2Fpostcss-syntax/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gucong3000%2Fpostcss-syntax/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gucong3000%2Fpostcss-syntax/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gucong3000","download_url":"https://codeload.github.com/gucong3000/postcss-syntax/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247445680,"owners_count":20939961,"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":["css","extension","postcss","postcss-syntax","switch","syntax"],"created_at":"2024-10-12T21:12:52.921Z","updated_at":"2025-04-06T07:14:11.950Z","avatar_url":"https://github.com/gucong3000.png","language":"JavaScript","readme":"PostCSS Syntax\n====\n\n[![NPM version](https://img.shields.io/npm/v/postcss-syntax.svg?style=flat-square)](https://www.npmjs.com/package/postcss-syntax)\n[![Travis](https://img.shields.io/travis/gucong3000/postcss-syntax.svg)](https://travis-ci.org/gucong3000/postcss-syntax)\n[![Travis](https://img.shields.io/travis/gucong3000/postcss-syntaxes.svg?label=integration)](https://travis-ci.org/gucong3000/postcss-syntaxes)\n[![Codecov](https://img.shields.io/codecov/c/github/gucong3000/postcss-syntax.svg)](https://codecov.io/gh/gucong3000/postcss-syntax)\n[![David](https://img.shields.io/david/dev/gucong3000/postcss-syntax.svg)](https://david-dm.org/gucong3000/postcss-syntax?type=dev)\n\n\u003cimg align=\"right\" width=\"95\" height=\"95\"\n\ttitle=\"Philosopher’s stone, logo of PostCSS\"\n\tsrc=\"http://postcss.github.io/postcss/logo.svg\"\u003e\n\npostcss-syntax can automatically switch the required [PostCSS](https://github.com/postcss/postcss) syntax by file extension/source\n\n## Getting Started\n\nFirst thing's first, install the module:\n\n```\nnpm install postcss-syntax --save-dev\n```\n\nIf you want support SCSS/SASS/LESS/SugarSS syntax, you need to install these module:\n\n- SCSS: [postcss-scss](https://github.com/postcss/postcss-scss)\n- SASS: [postcss-sass](https://github.com/aleshaoleg/postcss-sass)\n- LESS: [postcss-less](https://github.com/shellscape/postcss-less)\n- SugarSS: [sugarss](https://github.com/postcss/sugarss)\n\nIf you want support HTML (and HTML-like)/Markdown/CSS-in-JS file format, you need to install these module:\n\n- CSS-in-JS: [postcss-jsx](https://github.com/gucong3000/postcss-jsx)\n- HTML (and HTML-like): [postcss-html](https://github.com/gucong3000/postcss-html)\n- Markdown: [postcss-markdown](https://github.com/gucong3000/postcss-markdown)\n\n## Use Cases\n\n```js\nconst postcss = require('postcss');\nconst syntax = require('postcss-syntax')({\n\trules: [\n\t\t{\n\t\t\ttest: /\\.(?:[sx]?html?|[sx]ht|vue|ux|php)$/i,\n\t\t\textract: 'html',\n\t\t},\n\t\t{\n\t\t\ttest: /\\.(?:markdown|md)$/i,\n\t\t\textract: 'markdown',\n\t\t},\n\t\t{\n\t\t\ttest: /\\.(?:[cm]?[jt]sx?|es\\d*|pac)$/i,\n\t\t\textract: 'jsx',\n\t\t},\n\t\t{\n\t\t\t// custom language for file extension\n\t\t\ttest: /\\.postcss$/i,\n\t\t\tlang: 'scss'\n\t\t},\n\t\t{\n\t\t\t// custom language for file extension\n\t\t\ttest: /\\.customcss$/i,\n\t\t\tlang: 'custom'\n\t\t},\n\t],\n\n\t// custom parser for CSS (using `postcss-safe-parser`)\n\tcss: 'postcss-safe-parser',\n\t// custom parser for SASS (PostCSS-compatible syntax.)\n\tsass: require('postcss-sass'),\n\t// custom parser for SCSS (by module name)\n\tscss: 'postcss-scss',\n\t// custom parser for LESS (by module path)\n\tless: './node_modules/postcss-less',\n\t// custom parser for SugarSS\n\tsugarss: require('sugarss'),\n\t// custom parser for custom language\n\tcustom: require('postcss-custom-syntax'),\n\n});\npostcss(plugins).process(source, { syntax: syntax }).then(function (result) {\n\t// An alias for the result.css property. Use it with syntaxes that generate non-CSS output.\n\tresult.content\n});\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgucong3000%2Fpostcss-syntax","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgucong3000%2Fpostcss-syntax","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgucong3000%2Fpostcss-syntax/lists"}