├── .editorconfig ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── index.js ├── index.spec.js ├── package.json └── test └── fixtures ├── a.scss ├── b.scss ├── empty-dir ├── same-name.css └── same-name │ └── same-name.css ├── empty.css ├── empty ├── layouts │ ├── base.scss │ └── main.scss └── views │ └── index.scss ├── malformed.css ├── rebasing ├── otherdir │ ├── fromroot.css │ ├── imported.css │ └── nestedsub │ │ └── nested.css ├── root.css └── subdir │ ├── import.css │ ├── import_absolute.css │ └── insub.css ├── sourcemaps-import ├── main.css ├── main.css.map └── styles │ ├── main.css │ └── partial.css ├── sourcemaps-load ├── index.html ├── scss │ ├── a │ │ └── a.scss │ ├── b │ │ └── b.scss │ └── test-sass.scss └── server.js ├── sourcemaps ├── index.html ├── server.js └── styles │ ├── bar │ └── style-a.css │ └── foo │ └── baz │ └── style-b.css ├── test-sass.scss ├── test.css └── very-empty ├── more-empty └── empty.css └── neighbor-empty └── neighbor-empty └── more-empty └── content └── content.css /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | indent_size = 2 8 | indent_style = space 9 | insert_final_newline = true 10 | trim_trailing_whitespace = true -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .coverage 3 | node_modules 4 | test/**/*.generated.* 5 | test/**/*.min.css 6 | **/.DS_Store 7 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "13" 4 | - "12" 5 | - "10" 6 | after_script: "cat ./.coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js" 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2019 scniro 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # gulp-clean-css 2 | 3 | [![Build Status](https://img.shields.io/travis/scniro/gulp-clean-css.svg?style=flat-square)](https://travis-ci.org/scniro/gulp-clean-css) 4 | [![Dependency Status](https://img.shields.io/david/scniro/gulp-clean-css.svg?label=deps&style=flat-square)](https://david-dm.org/scniro/gulp-clean-css) 5 | [![devDependency Status](https://img.shields.io/david/dev/scniro/gulp-clean-css.svg?label=devDeps&style=flat-square)](https://david-dm.org/scniro/gulp-clean-css#info=devDependencies) 6 | [![Coverage](https://img.shields.io/coveralls/scniro/gulp-clean-css.svg?style=flat-square)](https://coveralls.io/github/scniro/gulp-clean-css) 7 | [![Downloads](https://img.shields.io/npm/dm/gulp-clean-css.svg?style=flat-square)](https://www.npmjs.com/package/gulp-clean-css) 8 | [![NPM Version](https://img.shields.io/npm/v/gulp-clean-css.svg?style=flat-square)](https://www.npmjs.com/package/gulp-clean-css) 9 | [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/alferov/awesome-gulp#minification) 10 | 11 | > [gulp](http://gulpjs.com/) plugin to minify CSS, using [clean-css](https://github.com/jakubpawlowicz/clean-css) 12 | 13 | ## Regarding Issues 14 | 15 | This is just a simple [gulp](https://github.com/gulpjs/gulp) plugin, which means it's nothing more than a thin wrapper around `clean-css`. If it looks like you are having CSS related issues, please contact [clean-css](https://github.com/jakubpawlowicz/clean-css/issues). Only create a new issue if it looks like you're having a problem with the plugin itself. 16 | 17 | ## Install 18 | 19 | ``` 20 | npm install gulp-clean-css --save-dev 21 | ``` 22 | 23 | ## API 24 | 25 | ### cleanCSS([*options*], [*callback*]) 26 | 27 | #### options 28 | 29 | See the [`CleanCSS` options](https://github.com/jakubpawlowicz/clean-css#how-to-use-clean-css-api). 30 | 31 | ```javascript 32 | const gulp = require('gulp'); 33 | const cleanCSS = require('gulp-clean-css'); 34 | 35 | gulp.task('minify-css', () => { 36 | return gulp.src('styles/*.css') 37 | .pipe(cleanCSS({compatibility: 'ie8'})) 38 | .pipe(gulp.dest('dist')); 39 | }); 40 | ``` 41 | 42 | #### callback 43 | 44 | Useful for returning details from the underlying [`minify()`](https://github.com/jakubpawlowicz/clean-css#using-api) call. An example use case could include logging `stats` of the minified file. In addition to the default object, `gulp-clean-css` provides the file `name` and `path` for further analysis. 45 | 46 | ```javascript 47 | const gulp = require('gulp'); 48 | const cleanCSS = require('gulp-clean-css'); 49 | 50 | gulp.task('minify-css', () => { 51 | return gulp.src('styles/*.css') 52 | .pipe(cleanCSS({debug: true}, (details) => { 53 | console.log(`${details.name}: ${details.stats.originalSize}`); 54 | console.log(`${details.name}: ${details.stats.minifiedSize}`); 55 | })) 56 | .pipe(gulp.dest('dist')); 57 | }); 58 | ``` 59 | 60 | [Source Maps](http://www.html5rocks.com/tutorials/developertools/sourcemaps/) can be generated by using [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps). 61 | 62 | ```javascript 63 | 64 | const gulp = require('gulp'); 65 | const cleanCSS = require('gulp-clean-css'); 66 | const sourcemaps = require('gulp-sourcemaps'); 67 | 68 | gulp.task('minify-css',() => { 69 | return gulp.src('./src/*.css') 70 | .pipe(sourcemaps.init()) 71 | .pipe(cleanCSS()) 72 | .pipe(sourcemaps.write()) 73 | .pipe(gulp.dest('dist')); 74 | }); 75 | ``` 76 | 77 | ## License 78 | 79 | [MIT](./LICENSE) © 2020 [scniro](https://github.com/scniro) 80 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const applySourceMap = require('vinyl-sourcemaps-apply'); 2 | const CleanCSS = require('clean-css'); 3 | const path = require('path'); 4 | const PluginError = require('plugin-error'); 5 | const through = require('through2'); 6 | 7 | module.exports = (options, callback) => { 8 | 9 | let _callback = callback || (o => undefined); 10 | 11 | return through.obj(function (file, enc, cb) { 12 | 13 | let _options = Object.assign({}, options || {}); 14 | 15 | if (file.isNull()) { 16 | return cb(null, file); 17 | } 18 | if (file.isStream()) { 19 | this.emit('error', new PluginError('gulp-clean-css', 'Streaming not supported!')); 20 | return cb(null, file); 21 | } 22 | 23 | if (file.sourceMap) { 24 | _options.sourceMap = JSON.parse(JSON.stringify(file.sourceMap)); 25 | } 26 | 27 | const content = { 28 | [file.path]: {styles: file.contents ? file.contents.toString() : ''} 29 | }; 30 | if (!_options.rebaseTo && _options.rebase !== false) { 31 | _options.rebaseTo = path.dirname(file.path); 32 | } 33 | 34 | new CleanCSS(_options).minify(content, (errors, css) => { 35 | 36 | if (errors) { 37 | return cb(errors.join(' ')); 38 | } 39 | 40 | let details = { 41 | 'stats': css.stats, 42 | 'errors': css.errors, 43 | 'warnings': css.warnings, 44 | 'path': file.path, 45 | 'name': file.path.split(file.base)[1] 46 | }; 47 | 48 | if (css.sourceMap) { 49 | details['sourceMap'] = css.sourceMap; 50 | } 51 | _callback(details); 52 | 53 | file.contents = new Buffer.from(css.styles); 54 | 55 | if (css.sourceMap) { 56 | const iMap = JSON.parse(css.sourceMap); 57 | const oMap = Object.assign({}, iMap, { 58 | file: path.relative(file.base, file.path), 59 | sources: iMap.sources.map(mapSrc => path.relative(file.base, mapSrc)) 60 | }); 61 | applySourceMap(file, oMap); 62 | } 63 | cb(null, file); 64 | }); 65 | }); 66 | }; 67 | -------------------------------------------------------------------------------- /index.spec.js: -------------------------------------------------------------------------------- 1 | const chai = require('chai'); 2 | const cleanCSS = require('.'); 3 | const concat = require('gulp-concat'); 4 | const File = require('vinyl'); 5 | const gulp = require('gulp'); 6 | const gulpSass = require('gulp-sass'); 7 | const rename = require('gulp-rename'); 8 | const sourcemaps = require('gulp-sourcemaps'); 9 | 10 | const expect = chai.expect; 11 | 12 | chai.should(); 13 | chai.use(require('chai-string')); 14 | 15 | describe('gulp-clean-css: init', () => { 16 | 17 | it('should return the gulp-clean-css object: required export', () => { 18 | expect(cleanCSS).to.exist; 19 | }); 20 | }); 21 | 22 | describe('gulp-clean-css: base functionality', () => { 23 | 24 | it('should play nicely with other plugins: gulp-sass: before', done => { 25 | 26 | let i = 0; 27 | 28 | gulp.src(['test/fixtures/**/*.scss', '!test/fixtures/empty/**', '!test/fixtures/sourcemaps-load/**']) 29 | .pipe(gulpSass()) 30 | .pipe(cleanCSS()) 31 | .pipe(rename({ 32 | suffix: '.generated', 33 | })) 34 | .pipe(gulp.dest('test/fixtures/')) 35 | .on('data', file => { 36 | i += 1; 37 | }) 38 | .once('end', () => { 39 | i.should.equal(3); 40 | done(); 41 | }); 42 | }); 43 | 44 | it('should allow the file through', done => { 45 | 46 | let i = 0; 47 | 48 | gulp.src('test/fixtures/test.css') 49 | .pipe(cleanCSS()) 50 | .on('data', file => { 51 | i += 1; 52 | }) 53 | .once('end', () => { 54 | i.should.equal(1); 55 | done(); 56 | }); 57 | }); 58 | 59 | it('should allow the file through: no options specified', done => { 60 | 61 | let i = 0; 62 | 63 | gulp.src('test/fixtures/test.css') 64 | .pipe(cleanCSS(details => { 65 | console.log('hi'); 66 | })) 67 | .on('data', file => { 68 | i += 1; 69 | }) 70 | .once('end', () => { 71 | i.should.equal(1); 72 | done(); 73 | }); 74 | }); 75 | 76 | it('should allow empty files through', done => { 77 | 78 | let i = 0; 79 | 80 | gulp.src('test/fixtures/empty.css') 81 | .pipe(cleanCSS()) 82 | .on('data', file => { 83 | i += 1; 84 | }) 85 | .once('end', () => { 86 | i.should.equal(1); 87 | done(); 88 | }); 89 | }); 90 | 91 | it('should allow the file through:empty file, pipe dest', done => { 92 | 93 | let i = 0; 94 | 95 | gulp.src('test/fixtures/empty/**/*.scss') 96 | .pipe(gulpSass()) 97 | .pipe(cleanCSS()) 98 | .pipe(rename({ 99 | suffix: '.generated', 100 | })) 101 | .pipe(gulp.dest(file => `${file.base}/empty-parsed`)) 102 | .on('data', file => { 103 | i += 1; 104 | }) 105 | .once('end', () => { 106 | i.should.equal(3); 107 | done(); 108 | }); 109 | }); 110 | 111 | it('should produce the expected file', done => { 112 | 113 | let mockFile = new File({ 114 | cwd: '/', 115 | base: '/test/', 116 | path: '/test/expected.test.css', 117 | contents: new Buffer.from('p{text-align:center;color:green}') 118 | }); 119 | 120 | gulp.src('test/fixtures/test.css') 121 | .pipe(cleanCSS()) 122 | .on('data', file => { 123 | file.contents.should.exist && expect(file.contents.toString()).to.equal(mockFile.contents.toString()); 124 | done(); 125 | }); 126 | }); 127 | 128 | it('should invoke optional callback with details specified in options: debug', done => { 129 | gulp.src('test/fixtures/test.css') 130 | .pipe(cleanCSS({debug: true}, (details) => { 131 | details.stats.should.exist && 132 | details.stats.originalSize.should.exist && 133 | details.stats.minifiedSize.should.exist; 134 | })) 135 | .on('data', file => { 136 | done(); 137 | }); 138 | }); 139 | 140 | it('should invoke optional callback with out options object supplied: return object hash', done => { 141 | 142 | let called = false; 143 | 144 | gulp.src('test/fixtures/test.css') 145 | .pipe(cleanCSS({}, details => { 146 | called = true; 147 | details.stats.should.exist && 148 | expect(details).to.have.ownProperty('stats') && 149 | expect(details).to.have.ownProperty('errors') && 150 | expect(details).to.have.ownProperty('warnings') && 151 | expect(details).to.not.have.ownProperty('sourceMap'); 152 | })) 153 | .on('data', (file) => { 154 | // 155 | }) 156 | .once('end', () => { 157 | expect(called).to.be.true; 158 | done(); 159 | }) 160 | }); 161 | 162 | it('should invoke optional callback without options object supplied: return object hash with sourceMap: true; return correct hash', done => { 163 | gulp.src('test/fixtures/test.css') 164 | .pipe(cleanCSS({sourceMap: true}, details => { 165 | details.stats.should.exist && 166 | expect(details).have.ownProperty('sourceMap'); 167 | })) 168 | .on('data', file => { 169 | done(); 170 | }); 171 | }); 172 | 173 | it('should invoke optional callback with file details returned', done => { 174 | 175 | let expected = 'test.css'; 176 | 177 | gulp.src('test/fixtures/test.css') 178 | .pipe(cleanCSS(details => { 179 | details.name.should.containIgnoreCase(expected) 180 | })) 181 | .on('data', file => { 182 | done(); 183 | }); 184 | }); 185 | 186 | it('should write sourcemaps', done => { 187 | 188 | let i = 0; 189 | 190 | gulp.src(['test/fixtures/sourcemaps/**/*.css', '!test/fixtures/sourcemaps/**/*.generated.css']) 191 | .pipe(sourcemaps.init()) 192 | .pipe(concat('sourcemapped.css')) 193 | .pipe(cleanCSS()) 194 | .pipe(rename({ 195 | suffix: '.generated', 196 | })) 197 | .on('data', file => { 198 | i += 1; 199 | }) 200 | .pipe(sourcemaps.write()) 201 | .pipe(gulp.dest(file => file.base)) 202 | .once('end', () => { 203 | i.should.equal(1); 204 | done(); 205 | }); 206 | }); 207 | 208 | it('should write sourcemaps, worrectly map output', done => { 209 | 210 | let i = 0; 211 | 212 | gulp.src('test/fixtures/sourcemaps-load/scss/test-sass.scss') 213 | .pipe(sourcemaps.init()) 214 | .pipe(gulpSass()) 215 | .pipe(sourcemaps.init({loadMaps: true})) 216 | .pipe(cleanCSS({sourceMapInlineSources: true})) 217 | .on('data', file => { 218 | i += 1; 219 | }) 220 | .pipe(rename({ 221 | suffix: '.min' 222 | })) 223 | .pipe(sourcemaps.write()) 224 | .pipe(gulp.dest('test/fixtures/sourcemaps-load/min')) 225 | .once('end', () => { 226 | i.should.equal(1); // todo inspect mapping here 227 | done(); 228 | }); 229 | }); 230 | 231 | it('should invoke a plugin error: streaming not supported', done => { 232 | 233 | gulp.src('test/fixtures/test.css', {buffer: false}) 234 | .pipe(cleanCSS() 235 | .on('error', err => { 236 | expect(err.message).to.equal('Streaming not supported!'); 237 | done(); 238 | })); 239 | }); 240 | 241 | it('should handle malformed CSS', done => { 242 | let i = 0; 243 | 244 | gulp.src('test/fixtures/malformed.css') 245 | .pipe(cleanCSS()) 246 | .on('error', e => { 247 | expect(e).to.exist; 248 | done(); 249 | }) 250 | }); 251 | 252 | it('should not process empty directories or files', done => { 253 | 254 | gulp.src('./test/fixtures/very-empty/**') 255 | .pipe(cleanCSS({}, detail => { 256 | expect(detail.errors).to.be.empty; 257 | })) 258 | .on('data', file => { 259 | // 260 | }) 261 | .on('end', () => { 262 | done(); 263 | }); 264 | }) 265 | 266 | it('should write sourcemaps, correct source path', done => { 267 | let maps = {}; 268 | gulp.src(['test/fixtures/sourcemaps-import/styles/main.css'], {base: 'test/fixtures/sourcemaps-import/styles'}) 269 | .pipe(sourcemaps.init()) 270 | .pipe(cleanCSS()) 271 | .pipe(sourcemaps.mapSources(function (sourcePath, file) { 272 | maps[sourcePath] = true; 273 | return sourcePath; 274 | })) 275 | .pipe(sourcemaps.write('./', {sourceRoot: '/'})) 276 | .pipe(gulp.dest('test/fixtures/sourcemaps-import')) 277 | .once('end', () => { 278 | maps['main.css'].should.be.true; 279 | maps['partial.css'].should.be.true; 280 | done(); 281 | }); 282 | }); 283 | }); 284 | 285 | describe('gulp-clean-css: rebase', () => { 286 | 287 | it('should not rebase files by default - do not resolve relative files', done => { 288 | 289 | gulp.src(['test/fixtures/rebasing/subdir/insub.css']) 290 | .pipe(cleanCSS({rebase: false})) 291 | .on('data', file => { 292 | 293 | let expected = ` 294 | p.insub_same{background:url(insub.png)} 295 | p.insub_child{background:url(child/child.png)} 296 | p.insub_parent{background:url(../parent.png)} 297 | p.insub_other{background:url(../othersub/inother.png)} 298 | p.insub_absolute{background:url(/inroot.png)}`; 299 | 300 | let actual = file.contents.toString(); 301 | 302 | expect(actual).to.equalIgnoreSpaces(expected) 303 | }) 304 | .once('end', done); 305 | }); 306 | 307 | it('should by rebase files with target specified', done => { 308 | 309 | gulp.src(['test/fixtures/rebasing/subdir/insub.css']) 310 | .pipe(cleanCSS({rebaseTo: 'test'})) 311 | .on('data', file => { 312 | 313 | let expected = ` 314 | p.insub_same{background:url(fixtures/rebasing/subdir/insub.png)} 315 | p.insub_child{background:url(fixtures/rebasing/subdir/child/child.png)} 316 | p.insub_parent{background:url(fixtures/rebasing/parent.png)} 317 | p.insub_other{background:url(fixtures/rebasing/othersub/inother.png)} 318 | p.insub_absolute{background:url(/inroot.png)}`; 319 | 320 | let actual = file.contents.toString(); 321 | 322 | expect(actual).to.equalIgnoreSpaces(expected); 323 | }) 324 | .once('end', done); 325 | }); 326 | 327 | it('should rebase to current relative file location - relative imports are resolved like in the browser', done => { 328 | 329 | gulp.src(['test/fixtures/rebasing/subdir/import.css']) 330 | .pipe(cleanCSS()) 331 | .on('data', file => { 332 | 333 | let expected = ` 334 | p.imported_nested{background:url(../otherdir/nestedsub/nested.png)} 335 | p.imported_same{background:url(../otherdir/imported.png)} 336 | p.imported_parent{background:url(../parent.png)} 337 | p.imported_other{background:url(../othersub/inother.png)} 338 | p.imported_absolute{background:url(/inroot.png)} 339 | p.insub_same{background:url(insub.png)} 340 | p.insub_child{background:url(child/child.png)} 341 | p.insub_parent{background:url(../parent.png)} 342 | p.insub_other{background:url(../othersub/inother.png)} 343 | p.insub_absolute{background:url(/inroot.png)} 344 | p.import{background:url(import.png)}`; 345 | 346 | let actual = file.contents.toString(); 347 | 348 | expect(actual).to.equalIgnoreSpaces(expected) 349 | }) 350 | .once('end', done); 351 | }); 352 | }); 353 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gulp-clean-css", 3 | "description": "Minify css with clean-css.", 4 | "homepage": "https://github.com/scniro/gulp-clean-css#readme", 5 | "version": "4.2.0", 6 | "author": "scniro", 7 | "license": "MIT", 8 | "bugs": { 9 | "url": "https://github.com/scniro/gulp-clean-css/issues", 10 | "email": "scniro@outlook.com" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "https://github.com/scniro/gulp-clean-css.git" 15 | }, 16 | "files": [ 17 | "index.js" 18 | ], 19 | "keywords": [ 20 | "css", 21 | "clean", 22 | "minify", 23 | "uglify", 24 | "clean-css", 25 | "minify-css", 26 | "gulp-minify-css", 27 | "gulp-clean-css", 28 | "gulpplugin", 29 | "gulpfriendly" 30 | ], 31 | "nyc": { 32 | "report-dir": "./.coverage", 33 | "reporter": [ 34 | "lcov", 35 | "text" 36 | ], 37 | "include": [ 38 | "index.js" 39 | ], 40 | "sourceMap": false, 41 | "temp-dir": "./.coverage/.nyc_output" 42 | }, 43 | "dependencies": { 44 | "clean-css": "4.2.1", 45 | "plugin-error": "1.0.1", 46 | "through2": "3.0.1", 47 | "vinyl-sourcemaps-apply": "0.2.1" 48 | }, 49 | "devDependencies": { 50 | "chai": "4.2.0", 51 | "chai-string": "1.5.0", 52 | "coveralls": "3.0.9", 53 | "express": "4.17.1", 54 | "fancy-log": "1.3.3", 55 | "gulp": "4.0.2", 56 | "gulp-concat": "2.6.1", 57 | "gulp-rename": "2.0.0", 58 | "gulp-sass": "4.0.2", 59 | "gulp-sourcemaps": "2.6.5", 60 | "mocha": "7.0.0", 61 | "nyc": "15.0.0", 62 | "vinyl": "2.2.0" 63 | }, 64 | "scripts": { 65 | "cover": "./node_modules/.bin/nyc npm test", 66 | "test": "./node_modules/.bin/mocha ./index.spec.js" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /test/fixtures/a.scss: -------------------------------------------------------------------------------- 1 | $color: red; -------------------------------------------------------------------------------- /test/fixtures/b.scss: -------------------------------------------------------------------------------- 1 | @import 'a.scss'; 2 | 3 | span { 4 | color: $color 5 | } -------------------------------------------------------------------------------- /test/fixtures/empty-dir/same-name.css: -------------------------------------------------------------------------------- 1 | p { 2 | text-align: center; 3 | color: green; 4 | } 5 | -------------------------------------------------------------------------------- /test/fixtures/empty-dir/same-name/same-name.css: -------------------------------------------------------------------------------- 1 | p { 2 | text-align: center; 3 | color: green; 4 | } 5 | -------------------------------------------------------------------------------- /test/fixtures/empty.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scniro/gulp-clean-css/7eddd7deabcea03b6c7abb02dd3da128d3c6477f/test/fixtures/empty.css -------------------------------------------------------------------------------- /test/fixtures/empty/layouts/base.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scniro/gulp-clean-css/7eddd7deabcea03b6c7abb02dd3da128d3c6477f/test/fixtures/empty/layouts/base.scss -------------------------------------------------------------------------------- /test/fixtures/empty/layouts/main.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scniro/gulp-clean-css/7eddd7deabcea03b6c7abb02dd3da128d3c6477f/test/fixtures/empty/layouts/main.scss -------------------------------------------------------------------------------- /test/fixtures/empty/views/index.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scniro/gulp-clean-css/7eddd7deabcea03b6c7abb02dd3da128d3c6477f/test/fixtures/empty/views/index.scss -------------------------------------------------------------------------------- /test/fixtures/malformed.css: -------------------------------------------------------------------------------- 1 | @import url(/some/fake/file); 2 | -------------------------------------------------------------------------------- /test/fixtures/rebasing/otherdir/fromroot.css: -------------------------------------------------------------------------------- 1 | p.fromroot 2 | { 3 | background: url(../sbudir/insubdir.png); 4 | } -------------------------------------------------------------------------------- /test/fixtures/rebasing/otherdir/imported.css: -------------------------------------------------------------------------------- 1 | @import url(nestedsub/nested.css); 2 | 3 | p.imported_same 4 | { 5 | background: url(imported.png); 6 | } 7 | p.imported_parent 8 | { 9 | background: url(../parent.png); 10 | } 11 | p.imported_other 12 | { 13 | background: url(../othersub/inother.png); 14 | } 15 | p.imported_absolute 16 | { 17 | background: url(/inroot.png); 18 | } 19 | -------------------------------------------------------------------------------- /test/fixtures/rebasing/otherdir/nestedsub/nested.css: -------------------------------------------------------------------------------- 1 | p.imported_nested 2 | { 3 | background: url(nested.png); 4 | } 5 | -------------------------------------------------------------------------------- /test/fixtures/rebasing/root.css: -------------------------------------------------------------------------------- 1 | @import url(otherdir/fromroot.css); 2 | p.root 3 | { 4 | background: url(inroot.png); 5 | } -------------------------------------------------------------------------------- /test/fixtures/rebasing/subdir/import.css: -------------------------------------------------------------------------------- 1 | @import url(../otherdir/imported.css); 2 | @import url(insub.css); 3 | 4 | p.import 5 | { 6 | background: url(import.png); 7 | } 8 | -------------------------------------------------------------------------------- /test/fixtures/rebasing/subdir/import_absolute.css: -------------------------------------------------------------------------------- 1 | @import url(../otherdir/imported.css); 2 | @import url(/rebasing/subdir/insub.css); 3 | @import url(/rebasing/root.css); 4 | 5 | p.import 6 | { 7 | background: url(import.png); 8 | } 9 | -------------------------------------------------------------------------------- /test/fixtures/rebasing/subdir/insub.css: -------------------------------------------------------------------------------- 1 | p.insub_same { 2 | background: url(insub.png); 3 | } 4 | 5 | p.insub_child { 6 | background: url(child/child.png); 7 | } 8 | 9 | p.insub_parent { 10 | background: url(../parent.png); 11 | } 12 | 13 | p.insub_other { 14 | background: url(../othersub/inother.png); 15 | } 16 | 17 | p.insub_absolute { 18 | background: url(/inroot.png); 19 | } -------------------------------------------------------------------------------- /test/fixtures/sourcemaps-import/main.css: -------------------------------------------------------------------------------- 1 | div{color:red}div{margin:10} 2 | /*# sourceMappingURL=main.css.map */ 3 | -------------------------------------------------------------------------------- /test/fixtures/sourcemaps-import/main.css.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["partial.css","main.css"],"names":[],"mappings":"AAAA,IACE,MAAM,ICCR,IACE,OAAO","file":"main.css","sourceRoot":"/","sourcesContent":["div {\n color:red;\n}\n","@import(partial.css);\n\ndiv {\n margin:10;\n}\n"]} -------------------------------------------------------------------------------- /test/fixtures/sourcemaps-import/styles/main.css: -------------------------------------------------------------------------------- 1 | @import(partial.css); 2 | 3 | div { 4 | margin:10; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/sourcemaps-import/styles/partial.css: -------------------------------------------------------------------------------- 1 | div { 2 | color:red; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/sourcemaps-load/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | gulp-clean-css: source maps 6 | 7 | 8 | 9 | 10 |

source maps

11 | 12 | -------------------------------------------------------------------------------- /test/fixtures/sourcemaps-load/scss/a/a.scss: -------------------------------------------------------------------------------- 1 | $color: red; -------------------------------------------------------------------------------- /test/fixtures/sourcemaps-load/scss/b/b.scss: -------------------------------------------------------------------------------- 1 | @import '../a/a'; 2 | 3 | span { 4 | color: $color 5 | } -------------------------------------------------------------------------------- /test/fixtures/sourcemaps-load/scss/test-sass.scss: -------------------------------------------------------------------------------- 1 | @import 'a/a'; 2 | @import 'b/b'; -------------------------------------------------------------------------------- /test/fixtures/sourcemaps-load/server.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var app = express(); 3 | 4 | app.set('port', 2000); 5 | 6 | app.use('/', express.static(__dirname)) 7 | 8 | app.get('/', function(req,res) { 9 | res.sendfile('index.html'); 10 | }); 11 | 12 | var server = app.listen(app.get('port'), function() { 13 | var port = server.address().port; 14 | console.log(`Magic happens on port ${port}`); 15 | }); -------------------------------------------------------------------------------- /test/fixtures/sourcemaps/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | gulp-clean-css: source maps 6 | 7 | 8 | 9 | 10 |

source maps

11 | 12 | -------------------------------------------------------------------------------- /test/fixtures/sourcemaps/server.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var app = express(); 3 | 4 | app.set('port', 1000); 5 | 6 | app.use('/', express.static(__dirname)) 7 | 8 | app.get('/', function(req,res) { 9 | res.sendfile('index.html'); 10 | }); 11 | 12 | var server = app.listen(app.get('port'), function() { 13 | var port = server.address().port; 14 | console.log(`Magic happens on port ${port}`); 15 | }); -------------------------------------------------------------------------------- /test/fixtures/sourcemaps/styles/bar/style-a.css: -------------------------------------------------------------------------------- 1 | span { 2 | color: dodgerblue; 3 | font-size: 16pt; 4 | } -------------------------------------------------------------------------------- /test/fixtures/sourcemaps/styles/foo/baz/style-b.css: -------------------------------------------------------------------------------- 1 | div { 2 | padding: 10px; 3 | margin: 0 auto; 4 | } -------------------------------------------------------------------------------- /test/fixtures/test-sass.scss: -------------------------------------------------------------------------------- 1 | @import 'a.scss'; 2 | @import 'b.scss'; -------------------------------------------------------------------------------- /test/fixtures/test.css: -------------------------------------------------------------------------------- 1 | p { 2 | text-align: center; 3 | color: green; 4 | } -------------------------------------------------------------------------------- /test/fixtures/very-empty/more-empty/empty.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scniro/gulp-clean-css/7eddd7deabcea03b6c7abb02dd3da128d3c6477f/test/fixtures/very-empty/more-empty/empty.css -------------------------------------------------------------------------------- /test/fixtures/very-empty/neighbor-empty/neighbor-empty/more-empty/content/content.css: -------------------------------------------------------------------------------- 1 | p { 2 | color: red; 3 | } 4 | --------------------------------------------------------------------------------