├── .editorconfig ├── .gitattributes ├── .github └── workflows │ └── main.yml ├── .gitignore ├── gruntfile.js ├── license ├── package.json ├── readme.md ├── tasks └── strip-css-comments.js └── test ├── fixture ├── expected.css └── original.css └── 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 | [{package.json,*.yml}] 11 | indent_style = space 12 | indent_size = 2 13 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 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 | - 14 14 | - 12 15 | - 10 16 | - 8 17 | - 6 18 | - 4 19 | - 0.12 20 | - 0.1 21 | steps: 22 | - uses: actions/checkout@v2 23 | - uses: actions/setup-node@v1 24 | with: 25 | node-version: ${{ matrix.node-version }} 26 | - run: npm install 27 | - run: npm test 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /gruntfile.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | module.exports = function (grunt) { 3 | grunt.initConfig({ 4 | stripCssComments: { 5 | strip: { 6 | files: { 7 | 'test/tmp/stripped.css': 'test/fixture/original.css' 8 | } 9 | } 10 | }, 11 | simplemocha: { 12 | test: { 13 | src: 'test/*.js' 14 | } 15 | }, 16 | clean: { 17 | test: ['test/tmp'] 18 | } 19 | }); 20 | 21 | grunt.loadTasks('tasks'); 22 | grunt.loadNpmTasks('grunt-contrib-clean'); 23 | grunt.loadNpmTasks('grunt-simple-mocha'); 24 | 25 | grunt.registerTask('default', ['clean', 'stripCssComments', 'simplemocha', 'clean']); 26 | }; 27 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) Sindre Sorhus (sindresorhus.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "grunt-strip-css-comments", 3 | "version": "1.3.0", 4 | "description": "Strip comments from CSS", 5 | "license": "MIT", 6 | "repository": "sindresorhus/grunt-strip-css-comments", 7 | "author": { 8 | "name": "Sindre Sorhus", 9 | "email": "sindresorhus@gmail.com", 10 | "url": "sindresorhus.com" 11 | }, 12 | "engines": { 13 | "node": ">=0.10.0" 14 | }, 15 | "scripts": { 16 | "test": "xo && grunt" 17 | }, 18 | "files": [ 19 | "tasks" 20 | ], 21 | "keywords": [ 22 | "gruntplugin", 23 | "css", 24 | "style", 25 | "stylesheet", 26 | "strip", 27 | "remove", 28 | "delete", 29 | "trim", 30 | "comments", 31 | "preprocess", 32 | "transform", 33 | "string" 34 | ], 35 | "dependencies": { 36 | "strip-css-comments": "^3.0.0" 37 | }, 38 | "devDependencies": { 39 | "grunt": "^1.0.1", 40 | "grunt-cli": "^1.2.0", 41 | "grunt-contrib-clean": "^1.0.0", 42 | "grunt-simple-mocha": "^0.4.0", 43 | "xo": "*" 44 | }, 45 | "peerDependencies": { 46 | "grunt": ">=0.4.0" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # grunt-strip-css-comments 2 | 3 | > Strip comments from CSS using [`strip-css-comments`](https://github.com/sindresorhus/strip-css-comments) 4 | 5 | 6 | ## Install 7 | 8 | ``` 9 | $ npm install --save-dev grunt-strip-css-comments 10 | ``` 11 | 12 | 13 | ## Usage 14 | 15 | ```js 16 | require('load-grunt-tasks')(grunt); // npm install --save-dev load-grunt-tasks 17 | 18 | grunt.initConfig({ 19 | stripCssComments: { 20 | dist: { 21 | files: { 22 | 'dist/app.css': 'src/app.css' 23 | } 24 | } 25 | } 26 | }); 27 | 28 | grunt.registerTask('default', ['stripCssComments']); 29 | ``` 30 | 31 | 32 | ## Options 33 | 34 | See the `strip-css-comments` [options](https://github.com/sindresorhus/strip-css-comments#options). 35 | 36 | 37 | ## License 38 | 39 | MIT © [Sindre Sorhus](https://sindresorhus.com) 40 | -------------------------------------------------------------------------------- /tasks/strip-css-comments.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var stripCssComments = require('strip-css-comments'); 3 | 4 | module.exports = function (grunt) { 5 | grunt.registerMultiTask('stripCssComments', 'Strip comments from CSS', function () { 6 | var opts = this.options(); 7 | 8 | this.files.forEach(function (el) { 9 | grunt.file.write(el.dest, stripCssComments(grunt.file.read(el.src), opts)); 10 | }); 11 | }); 12 | }; 13 | -------------------------------------------------------------------------------- /test/fixture/expected.css: -------------------------------------------------------------------------------- 1 | body{} 2 | -------------------------------------------------------------------------------- /test/fixture/original.css: -------------------------------------------------------------------------------- 1 | body{/**/} 2 | -------------------------------------------------------------------------------- /test/test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | /* eslint-env mocha */ 3 | var assert = require('assert'); 4 | var grunt = require('grunt'); 5 | 6 | it('should strip CSS comments', function () { 7 | var actual = grunt.file.read('test/tmp/stripped.css'); 8 | var expected = grunt.file.read('test/fixture/expected.css'); 9 | assert.equal(actual, expected); 10 | }); 11 | --------------------------------------------------------------------------------