{"id":13454677,"url":"https://github.com/sindresorhus/strip-css-comments","last_synced_at":"2025-04-04T20:10:38.051Z","repository":{"id":22273217,"uuid":"25607516","full_name":"sindresorhus/strip-css-comments","owner":"sindresorhus","description":"Strip comments from CSS","archived":false,"fork":false,"pushed_at":"2023-05-29T13:56:57.000Z","size":56,"stargazers_count":121,"open_issues_count":0,"forks_count":10,"subscribers_count":8,"default_branch":"main","last_synced_at":"2024-10-29T22:38:31.982Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"CSS","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/sindresorhus.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/funding.yml","license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/security.md","support":null,"governance":null},"funding":{"github":"sindresorhus","open_collective":"sindresorhus","custom":"https://sindresorhus.com/donate"}},"created_at":"2014-10-22T22:28:35.000Z","updated_at":"2024-06-24T04:33:32.000Z","dependencies_parsed_at":"2022-08-21T01:31:02.673Z","dependency_job_id":null,"html_url":"https://github.com/sindresorhus/strip-css-comments","commit_stats":{"total_commits":44,"total_committers":9,"mean_commits":4.888888888888889,"dds":"0.18181818181818177","last_synced_commit":"ac5b43038a5cad5fae54f789b69a73f0e937c93e"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fstrip-css-comments","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fstrip-css-comments/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fstrip-css-comments/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fstrip-css-comments/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sindresorhus","download_url":"https://codeload.github.com/sindresorhus/strip-css-comments/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247242678,"owners_count":20907134,"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":"2024-07-31T08:00:56.722Z","updated_at":"2025-04-04T20:10:38.028Z","avatar_url":"https://github.com/sindresorhus.png","language":"CSS","funding_links":["https://github.com/sponsors/sindresorhus","https://opencollective.com/sindresorhus","https://sindresorhus.com/donate"],"categories":["Packages","Repository","CSS","包","目录","Parsing","Number"],"sub_categories":["Parsing","Minifiers","解析","解析工具"],"readme":"# strip-css-comments\n\n\u003e Strip comments from CSS\n\nAlso available as a [Gulp](https://github.com/sindresorhus/gulp-strip-css-comments)/[Grunt](https://github.com/sindresorhus/grunt-strip-css-comments)/[Broccoli](https://github.com/sindresorhus/broccoli-strip-css-comments) plugin.\n\n## Usage\n\n```\n$ npm install strip-css-comments\n```\n\n## Usage\n\n```js\nimport stripCssComments from 'strip-css-comments';\n\n// By default important comments `/*!` are preserved\nstripCssComments('/*! \u003ccopyright\u003e */ body { /* unicorns */color: hotpink; }');\n//=\u003e '/*! \u003ccopyright\u003e */ body { color: hotpink; }'\n\n// `preserve: false` will strip all comments including `/*!`\nstripCssComments(\n\t'/*! \u003ccopyright\u003e */ body { /* unicorns */color: hotpink; }',\n\t{preserve: false}\n);\n//=\u003e 'body { color: hotpink; }'\n\n// Preserve comments based on a regex\nstripCssComments(\n\t'/*# preserved */ body { /* unicorns */color: hotpink; }',\n\t{preserve: /^#/}\n);\n//=\u003e '/*# preserved */ body { color: hotpink; }'\n\n// Preserve comments based on the return value of the supplied function\nstripCssComments(\n\t'/*# preserved */ body { /* unicorns */color: hotpink; }',\n\t{\n\t\tpreserve: comment =\u003e comment.charAt(0) === '#'\n\t}\n);\n//=\u003e '/*# preserved */ body { color: hotpink; }'\n```\n\n## API\n\n### stripCssComments(cssString, options?)\n\n## cssString\n\nType: `string`\n\nString with CSS.\n\n## options\n\nType: `object`\n\n### preserve\n\nType: `boolean | RegExp | Function`\\\nDefault: `true`\n\n- `true` - Preserve important comments `/*! */`.\n- `false` - Strip all comments.\n- `RegExp` - Preserve comments where the comment body matches a regular expression.\n- `Function` - Preserve comments for which a function returns `true`. The function is called on each comment, gets the comment body as the first argument, and is expected to return a boolean of whether to preserve the comment.\n\n### whitespace\n\nType: `boolean`\\\nDefault: `true`\n\nReplace comments with whitespace instead of stripping them entirely.\n\n## Benchmark\n\n```\n$ npm run bench\n```\n\n## Related\n\n- [strip-css-comments-cli](https://github.com/sindresorhus/strip-css-comments-cli) - CLI for this module\n- [strip-json-comments](https://github.com/sindresorhus/strip-json-comments) - Strip comments from JSON\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fstrip-css-comments","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsindresorhus%2Fstrip-css-comments","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fstrip-css-comments/lists"}