{"id":20395434,"url":"https://github.com/jpeer264/gulp-rcs","last_synced_at":"2025-10-05T11:27:06.208Z","repository":{"id":49516280,"uuid":"74307968","full_name":"JPeer264/gulp-rcs","owner":"JPeer264","description":"The gulp task to the main module rename-css-selectors","archived":false,"fork":false,"pushed_at":"2021-06-16T02:12:37.000Z","size":148,"stargazers_count":10,"open_issues_count":4,"forks_count":4,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-04-29T21:33:42.955Z","etag":null,"topics":["css","css-selector","gulp","matches-selector","minified-selectors","rcs","rename"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JPeer264.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-20T22:55:14.000Z","updated_at":"2023-04-13T13:37:42.000Z","dependencies_parsed_at":"2022-08-28T21:41:44.587Z","dependency_job_id":null,"html_url":"https://github.com/JPeer264/gulp-rcs","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JPeer264%2Fgulp-rcs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JPeer264%2Fgulp-rcs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JPeer264%2Fgulp-rcs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JPeer264%2Fgulp-rcs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JPeer264","download_url":"https://codeload.github.com/JPeer264/gulp-rcs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248565651,"owners_count":21125535,"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","css-selector","gulp","matches-selector","minified-selectors","rcs","rename"],"created_at":"2024-11-15T03:57:29.265Z","updated_at":"2025-10-05T11:26:59.827Z","avatar_url":"https://github.com/JPeer264.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gulp-rcs\n\n[![Build Status](https://travis-ci.com/JPeer264/gulp-rcs.svg?branch=main)](https://travis-ci.com/JPeer264/gulp-rcs)\n\n\u003e [rcs](https://www.github.com/jpeer264/node-rcs-core) plugin for [Gulp](https://github.com/gulpjs/gulp).\n\n\u003e Minify all CSS selectors across all files\n\n## Overview\n\n- [Install](#install)\n- [Basic Usage](#basic-usage-w-gulp-v3)\n- [RCS Options](#options)\n- [RCS Methods](#methods)\n\n## Install\n\n```sh\nnpm i rcs-core gulp-rcs -D\n```\n\nor\n\n```sh\nyarn add rcs-core gulp-rcs --dev\n```\n\n## Basic Usage (w/ Gulp v3)\n\n\u003e Make sure that you load all `css` files first. Files should **not** be minified/uglified.\n\nAll files at once:\n\n```js\nconst rcs = require('gulp-rcs');\n\ngulp.task('all', () =\u003e {\n    return gulp.src(['./src/**/*.css', './src/**/*.js', './src/**/*.html'])\n        .pipe(rcs())\n        .pipe(gulp.dest('./dist/'));\n});\n```\n\nSplitted (e.g. w/ [gulp-sass](https://github.com/dlmanning/gulp-sass)):\n\n```js\nconst rcs = require('gulp-rcs');\nconst sass = require('gulp-sass');\n\ngulp.task('css', () =\u003e {\n    return gulp.src('./src/sass/**/*.scss')\n        .pipe(sass().on('error', sass.logError))\n        .pipe(rcs())\n        .pipe(gulp.dest('./dist/'));\n});\n\n// here we will wait until, css is finished\ngulp.task('remainings', ['css'], () =\u003e {\n    // note that 'scss' files are here ignored\n    return gulp.src(['!./src/sass/**/*.scss', './src/**/*.js', './src/**/*.html'])\n        .pipe(rcs())\n        .pipe(gulp.dest('./dist/'));\n});\n\ngulp.task('default', ['css', 'remainings']);\n```\n\nWorking with mappings (the mapping can look like [this](https://github.com/JPeer264/gulp-rcs/blob/main/test/files/results/renaming_map.json)):\n\n```js\nconst rcs = require('gulp-rcs');\n\ngulp.task('all', () =\u003e {\n    return gulp.src(['./src/**/*.css', './src/**/*.js', './src/**/*.html'])\n        .pipe(rcs({\n            mapping: './config/renaming_map.json'\n        }))\n        ...\n        .pipe(rcs.writeMapping('./config'))\n})\n```\n\n## options\n\n- [excludeFile](#optionsexcludefile)\n- [exclude](#optionsexclude)\n- [config](#optionsconfig)\n- [mapping](#optionsmapping)\n- [mappingOrigValues](#optionsmappingorigvalues)\n- [css](#optionscss)\n- [prefix](#optionsprefix)\n- [suffix](#optionssuffix)\n- [preventRandomName](#optionspreventrandomname)\n- [replaceKeyframes](#optionsreplacekeyframes)\n\n**Short example how it could look like:**\n\n```js\nconst rcs = require('gulp-rcs');\n\ngulp.task('myTask', () =\u003e {\n    return gulp.src('**/*')\n        .pipe(rcs([options]))\n        .pipe(gulp.dest('./dist/'));\n});\n```\n\n### options.excludeFile\n\nExcludes specific files or directories.\n\nType: `Array` or `String`, any valid `glob` statement\n\n```js\n...\n    .pipe(rcs({\n        excludeFile: ['**/vendor.js', '**/another.js']\n    }))\n...\n```\n\n### options.exclude\n\nExcludes specific selectors.\n\nType: `Array` or `String`\n\n```js\n...\n    .pipe(rcs({\n        exclude: ['any-selector', 'to-exclude']\n    }))\n...\n```\n\n### options.config\n\nSet another path to the config file. If set to `false` it will not load any config file.\n\nType: `String` or `Boolean`\n\n```js\n...\n    .pipe(rcs({\n        config: './path/to/config/file'\n    }))\n...\n```\n\n### options.mapping\n\nLoads the mapping file to have always the same consistent renamings. Mappings can be loaded although they do not exist yet\n\nType: `String`\n\n```js\n...\n    .pipe(rcs({\n        mapping: 'path/to/the/mapping.json'\n    }))\n...\n```\n\n### options.mappingOrigValues\n\nIn case the min version of the mapping is saved, you have to set this option to `false`. Default: `true`\n\nType: `Boolean`\n\n```js\n...\n    .pipe(rcs({\n        mapping: 'path/to/the/mapping_min.json',\n        mappingOrigValues: false\n    }))\n...\n```\n\n### options.css\n\nEnable specific CSS files. Any given extension will be excepted.\n\nType: `Array` or `String`\n\nIn the following example only `.css` and `.scss` files will rename new selectors.\n\n```js\n...\n    .pipe(rcs({\n        css: ['.css', '.scss']\n    }))\n...\n```\n\n### options.prefix\n\nPrefixes all selectors, excluding the exludes.\n\nType: `String`\n\n```js\n...\n    .pipe(rcs({\n        prefix: 'my-super-cool-prefix-'\n    }))\n...\n```\n\n### options.suffix\n\nSuffixes all selectors, excluding the exludes.\n\nType: `String`\n\n```js\n...\n    .pipe(rcs({\n        suffix: '-my-suffix'\n    }))\n...\n```\n\n### options.preventRandomName\n\nDoes not rename the selectors (good for prefixing/suffixing).\n\nType: `Boolean`\n\n```js\n...\n    .pipe(rcs({\n        preventRandomName: true,\n        prefix: 'my-super-cool-prefix-' // prefix it, otherwise there is no real effect\n    }))\n...\n```\n\n### options.replaceKeyframes\n\nRenames the names in `animation-name` or `animation` if a specific `@keyframes` was triggered before. Default: `false`\n\nType: `Boolean`\n\n```js\n...\n    .pipe(rcs({\n        replaceKeyframes: true\n    }))\n...\n```\n\n## Methods\n\n### rcs.writeMapping\n\n`rcs.writeMapping(destPath[, options])`\n\n\u003e **Note:** This function should be at the end of the pipe (after all plugins)\n\nThis saves the mapping files to ensure all your project got the same selector replacements\n\n#### options\n\n- [cssMapping](#optionscssmapping)\n- [cssMappingMin](#optionscssmappingmin)\n\n##### options.cssMapping\n\nThis writes the mapping file. The **original** selectorname is the key. and the **renamed** selectorname is the value. The key has always the selector type (id `#` or class `.`). The string instead of a boolean will give the mapping an alternative name. The default name would be `renaming_map`\n\nType: `Boolean` or `String`\n\n```js\n...\n    .pipe(rcs())\n    ...\n    .pipe(rcs.writeMapping('./', {\n        cssMapping: 'my_mapping' // this will generate the mapping in `./my_mapping.json`\n    }))\n...\n```\n\n##### options.cssMappingMin\n\nThis writes the mapping file. The **renamed** selectorname is the key. and the **original** selectorname is the value (so the opposite of [cssMapping](#optionscssmapping)). The key has always the selector type (id `#` or class `.`). The string instead of a boolean will give the mapping an alternative name. The default name would be `renaming_map_min`\n\nType: `Boolean` or `String`\n\n```js\n...\n    .pipe(rcs())\n    ...\n    .pipe(rcs.writeMapping('./', {\n        cssMapping: false, // or leave it, if you still want to have it\n        cssMappingMin: 'my_mapping_min' // this will generate the mapping in `./my_mapping_min.json`\n    }))\n...\n```\n\n## License\n\nMIT © [Jan Peer Stöcklmair](https://www.jpeer.at/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpeer264%2Fgulp-rcs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjpeer264%2Fgulp-rcs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpeer264%2Fgulp-rcs/lists"}