├── .editorconfig ├── .gitattributes ├── .github └── workflows │ └── main.yml ├── .gitignore ├── .npmrc ├── index.js ├── license ├── package.json ├── readme.md └── test.js /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = tab 5 | end_of_line = lf 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | 10 | [*.yml] 11 | indent_style = space 12 | indent_size = 2 13 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | - push 4 | - pull_request 5 | jobs: 6 | test: 7 | name: Node.js ${{ matrix.node-version }} 8 | runs-on: ubuntu-latest 9 | strategy: 10 | fail-fast: false 11 | matrix: 12 | node-version: 13 | - 20 14 | - 18 15 | steps: 16 | - uses: actions/checkout@v4 17 | - uses: actions/setup-node@v4 18 | with: 19 | node-version: ${{ matrix.node-version }} 20 | - run: npm install 21 | - run: npm test 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | yarn.lock 3 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false 2 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | import {Buffer} from 'node:buffer'; 2 | import stripCssComments from 'strip-css-comments'; 3 | import {gulpPlugin} from 'gulp-plugin-extras'; 4 | 5 | export default function gulpStripCssComments(options) { 6 | return gulpPlugin('gulp-strip-css-comments', file => { 7 | file.contents = Buffer.from(stripCssComments(file.contents.toString(), options)); 8 | return file; 9 | }); 10 | } 11 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Sindre Sorhus (https://sindresorhus.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gulp-strip-css-comments", 3 | "version": "3.0.0", 4 | "description": "Strip comments from CSS", 5 | "license": "MIT", 6 | "repository": "sindresorhus/gulp-strip-css-comments", 7 | "funding": "https://github.com/sponsors/sindresorhus", 8 | "author": { 9 | "name": "Sindre Sorhus", 10 | "email": "sindresorhus@gmail.com", 11 | "url": "https://sindresorhus.com" 12 | }, 13 | "type": "module", 14 | "exports": "./index.js", 15 | "engines": { 16 | "node": ">=18" 17 | }, 18 | "scripts": { 19 | "test": "xo && ava" 20 | }, 21 | "files": [ 22 | "index.js" 23 | ], 24 | "keywords": [ 25 | "gulpplugin", 26 | "css", 27 | "style", 28 | "stylesheet", 29 | "strip", 30 | "remove", 31 | "delete", 32 | "trim", 33 | "comments", 34 | "preprocess", 35 | "transform", 36 | "string" 37 | ], 38 | "dependencies": { 39 | "gulp-plugin-extras": "^0.2.2", 40 | "strip-css-comments": "^5.0.0" 41 | }, 42 | "devDependencies": { 43 | "ava": "^5.3.1", 44 | "p-event": "^6.0.0", 45 | "vinyl": "^3.0.0", 46 | "xo": "^0.56.0" 47 | }, 48 | "peerDependencies": { 49 | "gulp": ">=4" 50 | }, 51 | "peerDependenciesMeta": { 52 | "gulp": { 53 | "optional": true 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # gulp-strip-css-comments 2 | 3 | > Strip comments from CSS using [`strip-css-comments`](https://github.com/sindresorhus/strip-css-comments) 4 | 5 | ## Install 6 | 7 | ```sh 8 | npm install --save-dev gulp-strip-css-comments 9 | ``` 10 | 11 | ## Usage 12 | 13 | ```js 14 | import gulp from 'gulp'; 15 | import stripCssComments from 'gulp-strip-css-comments'; 16 | 17 | export default () => ( 18 | gulp.src('src/app.css') 19 | .pipe(stripCssComments()) 20 | .pipe(gulp.dest('dist')) 21 | ); 22 | ``` 23 | 24 | ## stripCssComments(options?) 25 | 26 | ### options 27 | 28 | Type: `object` 29 | 30 | See the `strip-css-comments` [options](https://github.com/sindresorhus/strip-css-comments#options). 31 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | import {Buffer} from 'node:buffer'; 2 | import test from 'ava'; 3 | import Vinyl from 'vinyl'; 4 | import {pEvent} from 'p-event'; 5 | import stripCssComments from './index.js'; 6 | 7 | test('main', async t => { 8 | const stream = stripCssComments({whitespace: true}); 9 | const dataPromise = pEvent(stream, 'data'); 10 | 11 | stream.end(new Vinyl({ 12 | contents: Buffer.from('body{/* d */}'), 13 | })); 14 | 15 | const file = await dataPromise; 16 | t.is(file.contents.toString(), 'body{}'); 17 | }); 18 | 19 | test('whitespace option', async t => { 20 | const stream = stripCssComments({whitespace: false}); 21 | const dataPromise = pEvent(stream, 'data'); 22 | 23 | stream.end(new Vinyl({ 24 | contents: Buffer.from('body{/* foo */}'), 25 | })); 26 | 27 | const file = await dataPromise; 28 | t.is(file.contents.toString(), 'body{}'); 29 | }); 30 | --------------------------------------------------------------------------------