├── .eslintignore ├── .travis.yml ├── test ├── expected │ ├── compressed.css │ └── index.css ├── fixtures │ ├── import.css │ ├── import │ │ └── index.css │ ├── error.css │ └── index.css ├── options.js └── cssnext.js ├── .gitignore ├── .editorconfig ├── CHANGELOG.md ├── package.json ├── index.js ├── LICENSE ├── .eslintrc └── README.md /.eslintignore: -------------------------------------------------------------------------------- 1 | .gitignore -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: node_js 3 | -------------------------------------------------------------------------------- /test/expected/compressed.css: -------------------------------------------------------------------------------- 1 | .foo{color:#300} 2 | -------------------------------------------------------------------------------- /test/fixtures/import.css: -------------------------------------------------------------------------------- 1 | @import './index.css'; 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .DS_Store? 3 | node_modules 4 | -------------------------------------------------------------------------------- /test/fixtures/import/index.css: -------------------------------------------------------------------------------- 1 | @import '../index.css'; 2 | -------------------------------------------------------------------------------- /test/expected/index.css: -------------------------------------------------------------------------------- 1 | .foo { 2 | color: #300; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/error.css: -------------------------------------------------------------------------------- 1 | .foo { 2 | color: var(--red; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/index.css: -------------------------------------------------------------------------------- 1 | :root { 2 | --red: #300; 3 | } 4 | 5 | .foo { 6 | color: var(--red); 7 | } 8 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | [*] 5 | end_of_line = lf 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | indent_style = space 10 | indent_size = 2 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | 15 | [Makefile] 16 | indent_style = tab 17 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 1.0.1 - 2015-05-08 2 | 3 | - Fixed: incorrect relative path when dealing with multiple files that have 4 | different paths ([#5](https://github.com/cssnext/gulp-cssnext/pull/5)) 5 | 6 | # 1.0.0 - 2015-02-06 7 | 8 | - Changed: upgrade to cssnext v1.x 9 | 10 | # 0.6.0 - 2014-11-28 11 | 12 | - Upgrade to cssnext v0.6 13 | 14 | # 0.5.0 - 2014-11-13 15 | 16 | - Upgrade to cssnext v0.5.0 (postcss v3) 17 | 18 | # 0.4.0 - 2014-11-01 19 | 20 | - Upgrade to cssnext v0.4.1 21 | 22 | # 0.3.0 - 2014-08-24 23 | 24 | - Add `from` option automatically 25 | 26 | # 0.2.0 - 2014-08-22 27 | 28 | - Upgrade to cssnext v0.2.2 29 | 30 | # 0.1.0 - 2014-08-19 31 | 32 | First release using cssnext v0.1.0 33 | -------------------------------------------------------------------------------- /test/options.js: -------------------------------------------------------------------------------- 1 | var tape = require("tape") 2 | var gutil = require("gulp-util") 3 | var cssnext = require("..") 4 | 5 | var fs = require("fs") 6 | var path = require("path") 7 | 8 | tape("cssnext with options", function(test) { 9 | var stream = cssnext({ 10 | compress: true, 11 | }) 12 | var file = new gutil.File({ 13 | base: ".", 14 | path: ".", 15 | contents: new Buffer( 16 | fs.readFileSync( 17 | path.resolve(__dirname, "./fixtures/index.css"), 18 | "utf8" 19 | ) 20 | ), 21 | }) 22 | stream.on("data", function(data) { 23 | test.equal( 24 | data.contents.toString() + "\n", 25 | fs.readFileSync( 26 | path.resolve(__dirname, "./expected/compressed.css"), 27 | "utf8" 28 | ) 29 | ) 30 | test.end() 31 | }) 32 | stream.end(file) 33 | }) 34 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gulp-cssnext", 3 | "version": "1.0.1", 4 | "description": "Use tomorrow's CSS syntax, today, using cssnext via Gulp", 5 | "keywords": [ 6 | "css", 7 | "cssnext", 8 | "preprocessor", 9 | "postprocessor", 10 | "rework", 11 | "postcss", 12 | "autoprefixer", 13 | "gulp", 14 | "gulpplugin" 15 | ], 16 | "author": "bloodyowl", 17 | "license": "MIT", 18 | "repository": { 19 | "type": "git", 20 | "url": "git://github.com/cssnext/gulp-cssnext.git" 21 | }, 22 | "homepage": "http://cssnext.io/", 23 | "bugs": { 24 | "url": "https://github.com/cssnext/gulp-cssnext/issues" 25 | }, 26 | "files": [ 27 | "CHANGELOG.md", 28 | "LICENSE", 29 | "index.js" 30 | ], 31 | "dependencies": { 32 | "cssnext": "^1.0.0", 33 | "gulp-util": "^3.0.0", 34 | "through2": "^0.6.1" 35 | }, 36 | "devDependencies": { 37 | "eslint": "^0.22.1", 38 | "tape": "^3.0.0" 39 | }, 40 | "scripts": { 41 | "lint": "eslint .", 42 | "test": "npm run lint && tape 'test/**.js'" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | var through = require("through2") 2 | var cssnext = require("cssnext") 3 | var gutil = require("gulp-util") 4 | var PluginError = gutil.PluginError 5 | 6 | function transform(opts) { 7 | return function(file, enc, cb) { 8 | var contents 9 | var transformed 10 | var options = opts || {} 11 | if (file.isStream()) { 12 | return cb( 13 | new PluginError("gulp-cssnext", "streaming not supported") 14 | ) 15 | } 16 | if (file.isBuffer()) { 17 | contents = file.contents.toString() 18 | try { 19 | options.from = options.from === undefined 20 | ? ( 21 | file.path !== null 22 | ? file.path 23 | : undefined 24 | ) 25 | : options.from 26 | transformed = cssnext(contents, options) 27 | } 28 | catch(err) { 29 | return cb( 30 | new PluginError("gulp-cssnext", err) 31 | ) 32 | } 33 | file.contents = new Buffer(transformed) 34 | cb(null, file) 35 | } 36 | } 37 | } 38 | 39 | module.exports = function(options) { 40 | return through.obj(transform(options)) 41 | } 42 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | ## The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Putain de Code ! 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 all 13 | 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 THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | --- 2 | ecmaFeatures: 3 | modules: true 4 | 5 | env: 6 | es6: true 7 | browser: true 8 | node: true 9 | 10 | # 0: off, 1: warning, 2: error 11 | rules: 12 | # max 80 chars per line 13 | max-len: [2, 80, 4] 14 | 15 | # 2 spaces indentation 16 | indent: [2, 2] 17 | 18 | # double quote to match json 19 | quotes: [2, "double"] 20 | 21 | # semicolons are useless 22 | semi: [2, "never"] 23 | 24 | # consistent whitespace after keywords 25 | space-after-keywords: [2, "always"] 26 | 27 | # consistent whitespace before blocks 28 | space-before-blocks: [2, "always"] 29 | 30 | # consistent whitespace before function paren 31 | space-before-function-paren: [2, "never"] 32 | 33 | # consistent whitespace in brackets 34 | space-in-brackets: [2, "never"] 35 | 36 | # consistent whitespace in parens 37 | space-in-parens: [2, "never"] 38 | 39 | # consistent whitespace in single line comments 40 | spaced-line-comment: [2, "always"] 41 | 42 | # single empty lines only 43 | no-multiple-empty-lines: [2, {"max": 1}] 44 | 45 | # one brace per line 46 | brace-style: [2, "stroustrup"] 47 | 48 | # trailing coma are cool for diff 49 | comma-dangle: [2, "always-multiline"] 50 | 51 | # enforce comma at eol (never before) 52 | comma-style: [2, "last"] 53 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DEPRECATED. Use gulp-postcss instead. 2 | 3 | --- 4 | 5 | # gulp-[cssnext](https://github.com/cssnext/cssnext) 6 | 7 | [![Build Status](http://img.shields.io/travis/cssnext/gulp-cssnext.svg)](https://travis-ci.org/cssnext/gulp-cssnext) 8 | [![NPM version](http://img.shields.io/npm/v/gulp-cssnext.svg)](https://www.npmjs.org/package/gulp-cssnext) 9 | 10 | > Use tomorrow's CSS syntax, today. Via Gulp. 11 | 12 | **Issues with the output should be reported on [cssnext issue tracker](https://github.com/cssnext/cssnext/issues).** 13 | 14 | ## Install 15 | 16 | ```console 17 | $ npm install gulp-cssnext 18 | ``` 19 | 20 | ## Usage 21 | 22 | ```js 23 | var cssnext = require("gulp-cssnext") 24 | 25 | gulp.task("stylesheets", function() { 26 | gulp.src("src/stylesheets/index.css") 27 | .pipe(cssnext({ 28 | compress: true 29 | })) 30 | .pipe(gulp.dest("./dist/stylesheets")) 31 | }); 32 | ``` 33 | 34 | ### Options 35 | 36 | Options are directly passed to cssnext, so checkout [cssnext options](http://cssnext.io/usage/) directly. 37 | 38 | _Note: `from` option is by default automatically specified using gulp source._ 39 | 40 | --- 41 | 42 | ## Contributing 43 | 44 | Work on a branch, install dev-dependencies, respect coding style & run tests before submitting a bug fix or a feature. 45 | 46 | $ git clone https://github.com/cssnext/gulp-cssnext.git 47 | $ git checkout -b patch-1 48 | $ npm install 49 | $ npm test 50 | 51 | ## [Changelog](CHANGELOG.md) 52 | 53 | ## [License](LICENSE) 54 | -------------------------------------------------------------------------------- /test/cssnext.js: -------------------------------------------------------------------------------- 1 | var tape = require("tape") 2 | var gutil = require("gulp-util") 3 | var cssnext = require("..") 4 | 5 | var fs = require("fs") 6 | var path = require("path") 7 | 8 | tape("cssnext", function(test) { 9 | var stream = cssnext() 10 | var file = new gutil.File({ 11 | base: ".", 12 | path: ".", 13 | contents: new Buffer( 14 | fs.readFileSync( 15 | path.resolve(__dirname, "fixtures/index.css"), 16 | {encoding: "utf8"} 17 | ) 18 | ), 19 | }) 20 | 21 | stream.on("data", function(data) { 22 | test.equal( 23 | data.contents.toString(), 24 | fs.readFileSync( 25 | path.resolve(__dirname, "expected/index.css"), 26 | {encoding: "utf8"} 27 | ) 28 | ) 29 | test.end() 30 | }) 31 | stream.end(file) 32 | }) 33 | 34 | tape("cssnext throws if stream", function(test) { 35 | var stream = cssnext() 36 | var file = new gutil.File({ 37 | base: ".", 38 | path: ".", 39 | contents: fs.createReadStream( 40 | path.resolve(__dirname, "fixtures/index.css"), 41 | {encoding: "utf8"} 42 | ), 43 | }) 44 | stream.on("error", function(err) { 45 | test.equal(err.message, "streaming not supported") 46 | test.equal(err instanceof gutil.PluginError, true) 47 | test.end() 48 | }) 49 | stream.end(file) 50 | }) 51 | 52 | tape("throws on cssnext error", function(test) { 53 | var stream = cssnext() 54 | var file = new gutil.File({ 55 | base: ".", 56 | path: ".", 57 | contents: new Buffer( 58 | fs.readFileSync( 59 | path.resolve(__dirname, "fixtures/error.css"), 60 | {encoding: "utf8"} 61 | ) 62 | ), 63 | }) 64 | stream.on("error", function(err) { 65 | test.equal(err.message, path.resolve(".") + ":2:13: Unclosed bracket") 66 | test.equal(err instanceof gutil.PluginError, true) 67 | test.end() 68 | }) 69 | stream.end(file) 70 | }) 71 | 72 | tape( 73 | "Resolves relative paths for consecutive files in different paths", 74 | function(test) { 75 | var stream = cssnext() 76 | var file = new gutil.File({ 77 | base: "./test/fixtures/", 78 | path: "./test/fixtures/import.css", 79 | contents: new Buffer( 80 | fs.readFileSync( 81 | path.resolve(__dirname, "fixtures/import.css"), 82 | {encoding: "utf8"} 83 | ) 84 | ), 85 | }) 86 | stream.write(file) 87 | 88 | var file2 = new gutil.File({ 89 | base: "./test/fixtures/import/", 90 | path: "./test/fixtures/import/index.css", 91 | contents: new Buffer( 92 | fs.readFileSync( 93 | path.resolve(__dirname, "fixtures/import/index.css"), 94 | {encoding: "utf8"} 95 | ) 96 | ), 97 | }) 98 | stream.write(file2) 99 | 100 | var count = 0 101 | stream.on("data", function(data) { 102 | 103 | test.equal( 104 | data.contents.toString(), 105 | fs.readFileSync( 106 | path.resolve(__dirname, "expected/index.css"), 107 | {encoding: "utf8"} 108 | ) 109 | ) 110 | ++count 111 | if (count === 2) { 112 | test.end() 113 | } 114 | }) 115 | } 116 | ) 117 | --------------------------------------------------------------------------------