├── .editorconfig ├── .gitignore ├── .jshintrc ├── .travis.yml ├── CHANGELOG ├── Gruntfile.js ├── LICENSE ├── README.md ├── package.json ├── tasks └── autoprefixer.js └── test ├── expected ├── diff.css.diff ├── diff_path.css.diff ├── gradient.css ├── sm.css ├── sm.css.map ├── sm_annotation_path.css ├── sm_inline.css ├── sm_inline_update.css ├── sm_update.css ├── sm_update.css.map ├── sm_update_by_path.css ├── sm_update_by_path.css.map └── sm_void.css ├── fixtures ├── gradient.css ├── sm.css ├── sm.scss ├── sm_annotation_path.css ├── sm_inline_update.css ├── sm_inline_update.less ├── sm_update.css ├── sm_update.css.map └── sm_update.scss └── test.js /.editorconfig: -------------------------------------------------------------------------------- 1 | ; http://EditorConfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | indent_style = space 7 | indent_size = 4 8 | end_of_line = lf 9 | charset = utf-8 10 | trim_trailing_whitespace = true 11 | insert_final_newline = true 12 | 13 | [{*.css, *.map}] 14 | insert_final_newline = false 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea 3 | .sass-cache 4 | node_modules 5 | npm-debug.log 6 | tmp 7 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "curly": true, 3 | "eqeqeq": true, 4 | "expr": true, 5 | "immed": true, 6 | "latedef": true, 7 | "newcap": true, 8 | "noarg": true, 9 | "sub": true, 10 | "undef": true, 11 | "boss": true, 12 | "eqnull": true, 13 | "node": true 14 | } 15 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "0.10" 4 | - "0.12" 5 | - "iojs" 6 | before_script: 7 | - npm install -g grunt-cli 8 | -------------------------------------------------------------------------------- /CHANGELOG: -------------------------------------------------------------------------------- 1 | v3.0.4: 2 | date: 2016-02-16 3 | changes: 4 | - Update Grunt dependency (#pull/121) 5 | v3.0.3: 6 | date: 2015-06-10 7 | changes: 8 | - Fixed some async bugs 9 | v3.0.1: 10 | date: 2015-05-29 11 | changes: 12 | - Autoprefixer 5.2 support 13 | v3.0.0: 14 | date: 2015-04-03 15 | changes: 16 | - Abort Grunt on exceptions caught from external modules. Fix #92 and #93 17 | - Sourcemap `annotation` option now accepts string paths (#105) 18 | - Less verbose output in standard mode, `silent` option is no longer needed (#101) 19 | - io.js support 20 | v2.2.0: 21 | date: 2015-01-17 22 | changes: 23 | - Autoprefixer 5.0 24 | v2.1.0: 25 | date: 2014-12-31 26 | changes: 27 | - New `safe` option 28 | v2.0.0: 29 | date: 2014-11-14 30 | changes: 31 | - Autoprefixer 4.0 32 | - Maps now inline and containing sourcesContent by default 33 | - New `remove` option to control outdated prefixes cleaning (`true` by default) 34 | v1.0.1: 35 | date: 2014-08-23 36 | changes: 37 | - Autoprefixer 3.0. 38 | - Use new autoprefixer-core package designed for plugins. 39 | v1.0.0: 40 | date: 2014-08-05 41 | changes: 42 | - New ‘silent’ option to suppress logging to stdout 43 | - Diff files now created with .diff extension by default 44 | v0.8.2: 45 | date: 2014-07-18 46 | changes: 47 | - Use the caret operator for Autoprefixer's version. 48 | v0.8.1: 49 | date: 2014-06-30 50 | changes: 51 | - Autoprefixer 2.1. 52 | v0.8.0: 53 | date: 2014-06-26 54 | changes: 55 | - Autoprefixer 2.0. 56 | - New map option object notation. 57 | - Visual cascade is enabled by default. 58 | v0.7.6: 59 | date: 2014-06-22 60 | changes: 61 | - Autoprefixer 1.3. 62 | v0.7.5: 63 | date: 2014-06-10 64 | changes: 65 | - Autoprefixer 1.2. 66 | v0.7.4: 67 | date: 2014-06-06 68 | changes: 69 | - #45: Let users have both grunt-autoprefixer and autoprefixer NPM packages installed. 70 | v0.7.3: 71 | date: 2014-04-27 72 | changes: 73 | - #42: A warning message if no sources are found. 74 | v0.7.2: 75 | date: 2014-02-24 76 | changes: 77 | - New colorized terminal output. 78 | - Drop node.js 0.8 support. 79 | v0.7.1: 80 | date: 2014-02-20 81 | changes: 82 | - #31: `cascade` option support. 83 | v0.7.0: 84 | date: 2014-02-19 85 | changes: 86 | - #30: Autoprefixer 1.1 support. 87 | -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | /* 2 | * grunt-autoprefixer 3 | * 4 | * Copyright (c) 2013 Dmitry Nikitenko 5 | * Licensed under the MIT license. 6 | */ 7 | 8 | module.exports = function(grunt) { 9 | 10 | 'use strict'; 11 | 12 | require('load-grunt-tasks')(grunt); 13 | require('time-grunt')(grunt); 14 | 15 | grunt.initConfig({ 16 | jshint: { 17 | all: [ 18 | 'Gruntfile.js', 19 | 'tasks/*.js', 20 | '<%= nodeunit.tests %>', 21 | ], 22 | options: { 23 | jshintrc: '.jshintrc', 24 | }, 25 | }, 26 | 27 | clean: { 28 | tests: ['tmp'], 29 | }, 30 | 31 | copy: { 32 | single_no_dest: { 33 | src: 'test/fixtures/gradient.css', 34 | dest: 'tmp/no_dest.css' 35 | }, 36 | no_dest_multiple: { 37 | expand: true, 38 | flatten: true, 39 | src: 'test/fixtures/*.css', 40 | dest: 'tmp/no_dest_multiple/' 41 | } 42 | }, 43 | 44 | autoprefixer: { 45 | options: { 46 | // We need to `freeze` browsers versions for testing purposes. 47 | browsers: ['opera 12', 'ff 15', 'chrome 25'] 48 | }, 49 | 50 | single_file: { 51 | src: 'test/fixtures/gradient.css', 52 | dest: 'tmp/single_file.css' 53 | }, 54 | 55 | multiple_files: { 56 | expand: true, 57 | flatten: true, 58 | src: 'test/fixtures/*.css', 59 | dest: 'tmp/multiple_files/' 60 | }, 61 | 62 | no_dest_single: { 63 | src: 'tmp/no_dest.css' 64 | }, 65 | no_dest_multiple: { 66 | src: 'tmp/no_dest_multiple/*.css' 67 | }, 68 | 69 | diff: { 70 | options: { 71 | diff: true 72 | }, 73 | src: 'test/fixtures/gradient.css', 74 | dest: 'tmp/diff.css' 75 | }, 76 | diff_path: { 77 | options: { 78 | diff: 'tmp/diff_path.css.diff' 79 | }, 80 | src: 'test/fixtures/gradient.css', 81 | dest: 'tmp/diff_path.css' 82 | }, 83 | 84 | sm: { 85 | options: { 86 | map: { 87 | inline: false 88 | } 89 | }, 90 | src: 'test/fixtures/sm.css', 91 | dest: 'tmp/sm.css' 92 | }, 93 | sm_update: { 94 | options: { 95 | map: true 96 | }, 97 | src: 'test/fixtures/sm_update.css', 98 | dest: 'tmp/sm_update.css' 99 | }, 100 | sm_update_by_path: { 101 | options: { 102 | map: { 103 | inline: false, 104 | prev: 'test/fixtures/' 105 | } 106 | }, 107 | src: 'test/fixtures/sm_update.css', 108 | dest: 'tmp/sm_update_by_path.css' 109 | }, 110 | sm_void: { 111 | options: { 112 | map: false 113 | }, 114 | src: 'test/fixtures/sm_update.css', 115 | dest: 'tmp/sm_void.css' 116 | }, 117 | 118 | sm_inline: { 119 | options: { 120 | map: true 121 | }, 122 | src: 'test/fixtures/sm.css', 123 | dest: 'tmp/sm_inline.css' 124 | }, 125 | sm_inline_update: { 126 | options: { 127 | map: true 128 | }, 129 | src: 'test/fixtures/sm_inline_update.css', 130 | dest: 'tmp/sm_inline_update.css' 131 | }, 132 | sm_annotation_path: { 133 | options: { 134 | map: { 135 | inline: false, 136 | annotation: 'sm_updated_annotation.css.map' 137 | } 138 | }, 139 | src: 'test/fixtures/sm_annotation_path.css', 140 | dest: 'tmp/sm_annotation_path.css' 141 | }, 142 | log: { 143 | src: 'tmp/single_file.css', 144 | dest: 'tmp/single_file.css' 145 | } 146 | }, 147 | 148 | nodeunit: { 149 | tests: ['test/test.js'], 150 | }, 151 | 152 | }); 153 | 154 | grunt.loadTasks('tasks'); 155 | 156 | grunt.registerTask('test', ['clean', 'copy', 'autoprefixer', 'nodeunit']); 157 | grunt.registerTask('default', ['jshint', 'test']); 158 | 159 | }; 160 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) Dmitry Nikitenko 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Deprecation notice 2 | 3 | ### This project has been deprecated in favour of [grunt-postcss](https://github.com/nDmitry/grunt-postcss). 4 | 5 | # grunt-autoprefixer 6 | [![Build Status](https://travis-ci.org/nDmitry/grunt-autoprefixer.png?branch=master)](https://travis-ci.org/nDmitry/grunt-autoprefixer) 7 | [![Dependency Status](https://david-dm.org/nDmitry/grunt-autoprefixer.png)](https://david-dm.org/nDmitry/grunt-autoprefixer) 8 | [![Built with Grunt](https://cdn.gruntjs.com/builtwith.png)](http://gruntjs.com/) 9 | 10 | > [Autoprefixer](https://github.com/postcss/autoprefixer) parses CSS and adds vendor-prefixed CSS properties using the [Can I Use](http://caniuse.com/) database. 11 | 12 | ## Getting Started 13 | This plugin requires Grunt `~0.4.0` 14 | 15 | If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command: 16 | 17 | ```shell 18 | npm install grunt-autoprefixer --save-dev 19 | ``` 20 | 21 | Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript: 22 | 23 | ```js 24 | grunt.loadNpmTasks('grunt-autoprefixer'); 25 | ``` 26 | 27 | ## The "autoprefixer" task 28 | 29 | ### Overview 30 | In your project's Gruntfile, add a section named `autoprefixer` to the data object passed into `grunt.initConfig()`. 31 | 32 | ```js 33 | grunt.initConfig({ 34 | autoprefixer: { 35 | options: { 36 | // Task-specific options go here. 37 | }, 38 | your_target: { 39 | // Target-specific file lists and/or options go here. 40 | }, 41 | }, 42 | }) 43 | ``` 44 | 45 | ### Options 46 | 47 | #### options.browsers 48 | Type: `Array` 49 | Default value: an array with [default browsers](https://github.com/ai/browserslist) 50 | 51 | You can specify browsers actual for your project using this option: 52 | 53 | ```js 54 | options: { 55 | browsers: ['last 2 versions', 'ie 8', 'ie 9'] 56 | } 57 | ``` 58 | 59 | Or using a global config file named `browserslist` at the root of your project: 60 | 61 | ``` 62 | # Browsers that we support 63 | 64 | > 5% in US 65 | Last 2 versions 66 | ``` 67 | 68 | Read more about browserslist [here](https://github.com/ai/browserslist). 69 | 70 | #### options.cascade 71 | Type: `Boolean` 72 | Default value: `true` 73 | 74 | Pass `false` to disable ‘cascade’ indentation. Read more [here](https://github.com/postcss/autoprefixer#visual-cascade). 75 | 76 | #### options.remove 77 | Type: `Boolean` 78 | Default value: `true` 79 | 80 | Pass `false` to disable outdated prefixes cleaning. Read more [here](https://github.com/postcss/autoprefixer/releases/tag/4.0.0). 81 | 82 | #### options.diff 83 | Type: `Boolean|String` 84 | Default value: `false` 85 | 86 | Set it to `true` if you want to get an output patch file: 87 | 88 | ```js 89 | options: { 90 | diff: true // or 'custom/path/to/file.css.patch' 91 | } 92 | ``` 93 | Also you can specify a path where to save this file. More examples in [Gruntfile](https://github.com/nDmitry/grunt-autoprefixer/blob/master/Gruntfile.js). 94 | 95 | #### options.map 96 | Type: `Boolean|Object` 97 | Default value: `false` 98 | 99 | If the `map` option isn't defined or is set to `false`, Autoprefixer will neither create nor update a sourcemap. 100 | 101 | If `true` is specified, Autoprefixer will try to find a sourcemap from a previous compilation step using an annotation comment (e.g. from Sass) and create a new sourcemap based on the found one (or just create a new inlined sourcemap). The created sourcemap can be either a separate file or an inlined map depending on what the previous sourcemap was. 102 | 103 | You can gain more control over sourcemap generation by setting an object to the `map` option: 104 | 105 | * `prev` (string or `false`): a path to a directory where a previous sourcemap is (e.g. `path/`). By default, Autoprefixer will try to find a previous sourcemap using a path from the annotation comment (or using the annotation comment itself if the map is inlined). You can also set this option to `false` to delete the previous sourcemap. 106 | * `inline` (boolean): whether a sourcemap will be inlined or not. By default, it will be the same as a previous sourcemap or inlined. 107 | * `annotation` (string): set this option to URL path you wish the annotation comment to be e.g. `path/file.css.map` (by default, Autoprefixer will save your sourcemap to a directory where you save CSS). This option requires `inline` to be `false` or undefined. 108 | * `sourcesContent` (boolean): whether original contents (e.g. Sass sources) will be included to a sourcemap. By default, Autoprefixer will add contents only for new sourcemaps or if a previous sourcemap has them. 109 | 110 | #### options.safe 111 | Type: `Boolean` 112 | Default value: `false` 113 | 114 | Enable or disable [PostCSS safe mode](https://github.com/postcss/postcss#safe-mode). 115 | 116 | ```js 117 | options: { 118 | safe: true 119 | } 120 | ``` 121 | 122 | Check out project's [Gruntfile.js](https://github.com/nDmitry/grunt-autoprefixer/blob/master/Gruntfile.js) for more examples. 123 | 124 | ### Updating prefixes database 125 | 126 | ``` 127 | $ npm update caniuse-db 128 | ``` 129 | 130 | ## Contributing 131 | In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/). 132 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "grunt-autoprefixer", 3 | "version": "3.0.4", 4 | "description": "Parse CSS and add vendor-prefixed CSS properties using the Can I Use database. Based on Autoprefixer.", 5 | "author": { 6 | "name": "Dmitry Nikitenko", 7 | "email": "dima.nikitenko@gmail.com" 8 | }, 9 | "repository": "nDmitry/grunt-autoprefixer", 10 | "license": "MIT", 11 | "engines": { 12 | "node": ">= 0.10.0" 13 | }, 14 | "scripts": { 15 | "test": "grunt test" 16 | }, 17 | "keywords": [ 18 | "gruntplugin", 19 | "css", 20 | "postprocessor", 21 | "prefix", 22 | "autoprefixer" 23 | ], 24 | "files": [ 25 | "tasks", 26 | "LICENSE" 27 | ], 28 | "dependencies": { 29 | "autoprefixer-core": "^5.1.7", 30 | "chalk": "~1.0.0", 31 | "diff": "~1.3.0", 32 | "postcss": "^4.1.11" 33 | }, 34 | "devDependencies": { 35 | "grunt": "~0.4.4", 36 | "grunt-contrib-jshint": "~0.10.0", 37 | "grunt-contrib-clean": "~0.6.0", 38 | "grunt-contrib-nodeunit": "~0.4.0", 39 | "grunt-contrib-copy": "~0.7.0", 40 | "load-grunt-tasks": "~2.0.0", 41 | "time-grunt": "~1.0.0" 42 | }, 43 | "peerDependencies": { 44 | "grunt": ">=0.4.2" 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /tasks/autoprefixer.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var path = require('path'); 4 | var postcss = require('postcss'); 5 | var autoprefixer = require('autoprefixer-core'); 6 | var diff = require('diff'); 7 | var chalk = require('chalk'); 8 | 9 | module.exports = function(grunt) { 10 | 11 | var options; 12 | var prefixer; 13 | 14 | /** 15 | * Returns an input map contents if a custom map path was specified 16 | * @param {string} from Input CSS path 17 | * @returns {?string} 18 | */ 19 | function getPrevMap(from) { 20 | if (typeof options.map.prev === 'string') { 21 | var mapPath = options.map.prev + path.basename(from) + '.map'; 22 | 23 | if (grunt.file.exists(mapPath)) { 24 | return grunt.file.read(mapPath); 25 | } 26 | } 27 | } 28 | 29 | /** 30 | * @param {string} input Input CSS contents 31 | * @param {string} from Input CSS path 32 | * @param {string} to Output CSS path 33 | * @returns {{css: string, map: ?string}} 34 | */ 35 | function prefix(input, from, to) { 36 | return prefixer.process(input, { 37 | map: (typeof options.map === 'boolean') ? options.map : { 38 | prev: getPrevMap(from), 39 | inline: (typeof options.map.inline === 'boolean') ? options.map.inline : true, 40 | annotation: (typeof options.map.annotation === 'string') ? options.map.annotation : true, 41 | sourcesContent: (typeof options.map.sourcesContent === 'boolean') ? options.map.sourcesContent : true 42 | }, 43 | from: from, 44 | to: to, 45 | safe: options.safe 46 | }); 47 | } 48 | 49 | /** 50 | * @param {string} msg Log message 51 | */ 52 | function log(msg) { 53 | grunt.verbose.writeln(msg); 54 | } 55 | 56 | grunt.registerMultiTask('autoprefixer', 'Prefix CSS files.', function() { 57 | options = this.options({ 58 | browsers: undefined, 59 | cascade: true, 60 | diff: false, 61 | map: false, 62 | remove: true, 63 | safe: false 64 | }); 65 | 66 | var tally = { 67 | sheets: 0, 68 | maps: 0, 69 | diffs: 0 70 | }; 71 | 72 | prefixer = postcss([autoprefixer({ 73 | browsers: options.browsers, 74 | cascade: options.cascade, 75 | remove: options.remove 76 | })]); 77 | 78 | var done = this.async(); 79 | var finished = 0; 80 | var processed = this.files.length; 81 | 82 | if (!this.files.length) { 83 | done(); 84 | } 85 | 86 | this.files.forEach(function(f) { 87 | var src = f.src.filter(function(filepath) { 88 | if (!grunt.file.exists(filepath)) { 89 | grunt.log.warn('Source file ' + chalk.cyan(filepath) + ' not found.'); 90 | 91 | return false; 92 | } 93 | 94 | return true; 95 | }); 96 | 97 | if (src.length === 0) { 98 | grunt.log.error('No source files were found.'); 99 | 100 | return done(); 101 | } 102 | 103 | src.forEach(function(filepath) { 104 | var dest = f.dest || filepath; 105 | var input = grunt.file.read(filepath); 106 | 107 | prefix(input, filepath, dest).then(function(result) { 108 | result.warnings().forEach(function (msg) { 109 | grunt.log.error(msg.toString()); 110 | }); 111 | 112 | grunt.file.write(dest, result.css); 113 | log('File ' + chalk.cyan(dest) + ' created.'); 114 | tally.sheets++; 115 | 116 | if (result.map) { 117 | grunt.file.write(dest + '.map', result.map.toString()); 118 | log('File ' + chalk.cyan(dest + '.map') + ' created (source map).'); 119 | tally.maps++; 120 | } 121 | 122 | if (options.diff) { 123 | var diffPath = (typeof options.diff === 'string') ? options.diff : dest + '.diff'; 124 | 125 | grunt.file.write(diffPath, diff.createPatch(dest, input, result.css)); 126 | log('File ' + chalk.cyan(diffPath) + ' created (diff).'); 127 | tally.diffs++; 128 | } 129 | 130 | finished += 1; 131 | 132 | if (finished === processed) { 133 | if (tally.sheets) { 134 | grunt.log.ok(tally.sheets + ' ' + 'autoprefixed ' + grunt.util.pluralize(tally.sheets, 'stylesheet/stylesheets') + ' created.'); 135 | } 136 | 137 | if (tally.maps) { 138 | grunt.log.ok(tally.maps + ' ' + grunt.util.pluralize(tally.maps, 'sourcemap/sourcemaps') + ' created.'); 139 | } 140 | 141 | if (tally.diffs) { 142 | grunt.log.ok(tally.diffs + ' ' + grunt.util.pluralize(tally.diffs, 'diff/diffs') + ' created.'); 143 | } 144 | 145 | done(); 146 | } 147 | }).catch(function (error) { 148 | if (error.name === 'CssSyntaxError') { 149 | grunt.fatal(error.message + error.showSourceCode()); 150 | } else { 151 | grunt.fatal(error); 152 | } 153 | }); 154 | }); 155 | }); 156 | }); 157 | }; 158 | -------------------------------------------------------------------------------- /test/expected/diff.css.diff: -------------------------------------------------------------------------------- 1 | Index: tmp/diff.css 2 | =================================================================== 3 | --- tmp/diff.css 4 | +++ tmp/diff.css 5 | @@ -1,3 +1,6 @@ 6 | .test { 7 | + background: -webkit-linear-gradient(#000, #111); 8 | + background: -moz-linear-gradient(#000, #111); 9 | + background: -o-linear-gradient(#000, #111); 10 | background: linear-gradient(#000, #111); 11 | } 12 | -------------------------------------------------------------------------------- /test/expected/diff_path.css.diff: -------------------------------------------------------------------------------- 1 | Index: tmp/diff_path.css 2 | =================================================================== 3 | --- tmp/diff_path.css 4 | +++ tmp/diff_path.css 5 | @@ -1,3 +1,6 @@ 6 | .test { 7 | + background: -webkit-linear-gradient(#000, #111); 8 | + background: -moz-linear-gradient(#000, #111); 9 | + background: -o-linear-gradient(#000, #111); 10 | background: linear-gradient(#000, #111); 11 | } 12 | -------------------------------------------------------------------------------- /test/expected/gradient.css: -------------------------------------------------------------------------------- 1 | .test { 2 | background: -webkit-linear-gradient(#000, #111); 3 | background: -moz-linear-gradient(#000, #111); 4 | background: -o-linear-gradient(#000, #111); 5 | background: linear-gradient(#000, #111); 6 | } 7 | -------------------------------------------------------------------------------- /test/expected/sm.css: -------------------------------------------------------------------------------- 1 | .bg1 { 2 | background: -webkit-linear-gradient(black, #111111); 3 | background: -moz-linear-gradient(black, #111111); 4 | background: -o-linear-gradient(black, #111111); 5 | background: linear-gradient(black, #111111); } 6 | 7 | .bg2 { 8 | background: -webkit-linear-gradient(#111111, #222222); 9 | background: -moz-linear-gradient(#111111, #222222); 10 | background: -o-linear-gradient(#111111, #222222); 11 | background: linear-gradient(#111111, #222222); } 12 | 13 | /*# sourceMappingURL=sm.css.map */ -------------------------------------------------------------------------------- /test/expected/sm.css.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["../test/fixtures/sm.css"],"names":[],"mappings":"AAAA;EACE,oDAA4C;EAA5C,iDAA4C;EAA5C,+CAA4C;EAA5C,4CAA4C,EAAE;;AAEhD;EACE,sDAA8C;EAA9C,mDAA8C;EAA9C,iDAA8C;EAA9C,8CAA8C,EAAE","file":"sm.css","sourcesContent":[".bg1 {\n background: linear-gradient(black, #111111); }\n\n.bg2 {\n background: linear-gradient(#111111, #222222); }\n"]} -------------------------------------------------------------------------------- /test/expected/sm_annotation_path.css: -------------------------------------------------------------------------------- 1 | .bg1 { 2 | background: -webkit-linear-gradient(black, #111111); 3 | background: -moz-linear-gradient(black, #111111); 4 | background: -o-linear-gradient(black, #111111); 5 | background: linear-gradient(black, #111111); } 6 | 7 | .bg2 { 8 | background: -webkit-linear-gradient(#111111, #222222); 9 | background: -moz-linear-gradient(#111111, #222222); 10 | background: -o-linear-gradient(#111111, #222222); 11 | background: linear-gradient(#111111, #222222); } 12 | 13 | /*# sourceMappingURL=sm_updated_annotation.css.map */ -------------------------------------------------------------------------------- /test/expected/sm_inline.css: -------------------------------------------------------------------------------- 1 | .bg1 { 2 | background: -webkit-linear-gradient(black, #111111); 3 | background: -moz-linear-gradient(black, #111111); 4 | background: -o-linear-gradient(black, #111111); 5 | background: linear-gradient(black, #111111); } 6 | 7 | .bg2 { 8 | background: -webkit-linear-gradient(#111111, #222222); 9 | background: -moz-linear-gradient(#111111, #222222); 10 | background: -o-linear-gradient(#111111, #222222); 11 | background: linear-gradient(#111111, #222222); } 12 | 13 | /*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3Rlc3QvZml4dHVyZXMvc20uY3NzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBO0VBQ0Usb0RBQTRDO0VBQTVDLGlEQUE0QztFQUE1QywrQ0FBNEM7RUFBNUMsNENBQTRDLEVBQUU7O0FBRWhEO0VBQ0Usc0RBQThDO0VBQTlDLG1EQUE4QztFQUE5QyxpREFBOEM7RUFBOUMsOENBQThDLEVBQUUiLCJmaWxlIjoic21faW5saW5lLmNzcyIsInNvdXJjZXNDb250ZW50IjpbIi5iZzEge1xuICBiYWNrZ3JvdW5kOiBsaW5lYXItZ3JhZGllbnQoYmxhY2ssICMxMTExMTEpOyB9XG5cbi5iZzIge1xuICBiYWNrZ3JvdW5kOiBsaW5lYXItZ3JhZGllbnQoIzExMTExMSwgIzIyMjIyMik7IH1cbiJdfQ== */ -------------------------------------------------------------------------------- /test/expected/sm_inline_update.css: -------------------------------------------------------------------------------- 1 | .bg1 { 2 | background: -webkit-linear-gradient(#000000, #111111); 3 | background: -moz-linear-gradient(#000000, #111111); 4 | background: -o-linear-gradient(#000000, #111111); 5 | background: linear-gradient(#000000, #111111); 6 | } 7 | .bg2 { 8 | background: -webkit-linear-gradient(#111111, #222222); 9 | background: -moz-linear-gradient(#111111, #222222); 10 | background: -o-linear-gradient(#111111, #222222); 11 | background: linear-gradient(#111111, #222222); 12 | } 13 | 14 | /*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3Rlc3QvZml4dHVyZXMvc21faW5saW5lX3VwZGF0ZS5sZXNzIiwiLi4vdGVzdC9maXh0dXJlcy9zbV9pbmxpbmVfdXBkYXRlLmNzcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTtFQUNFLHNEQUFBO0VBQUEsbURBQUE7RUFBQSxpREFBQTtFQUFBLDhDQUFBO0NDQ0Q7QURFRDtFQUNFLHNEQUFBO0VBQUEsbURBQUE7RUFBQSxpREFBQTtFQUFBLDhDQUFBO0NDQUQiLCJmaWxlIjoic21faW5saW5lX3VwZGF0ZS5jc3MifQ== */ -------------------------------------------------------------------------------- /test/expected/sm_update.css: -------------------------------------------------------------------------------- 1 | .bg1 { 2 | background: -webkit-linear-gradient(black, #111111); 3 | background: -moz-linear-gradient(black, #111111); 4 | background: -o-linear-gradient(black, #111111); 5 | background: linear-gradient(black, #111111); } 6 | 7 | .bg2 { 8 | background: -webkit-linear-gradient(#111111, #222222); 9 | background: -moz-linear-gradient(#111111, #222222); 10 | background: -o-linear-gradient(#111111, #222222); 11 | background: linear-gradient(#111111, #222222); } 12 | /*# sourceMappingURL=sm_update.css.map */ -------------------------------------------------------------------------------- /test/expected/sm_update.css.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["../test/fixtures/sm_update.scss"],"names":[],"mappings":"AAAA;EACE,oDAAuC;EAAvC,iDAAuC;EAAvC,+CAAuC;EAAvC,4CAAuC,EAAA;;AAGzC;EACE,sDAAuC;EAAvC,mDAAuC;EAAvC,iDAAuC;EAAvC,8CAAuC,EAAA","file":"sm_update.css"} -------------------------------------------------------------------------------- /test/expected/sm_update_by_path.css: -------------------------------------------------------------------------------- 1 | .bg1 { 2 | background: -webkit-linear-gradient(black, #111111); 3 | background: -moz-linear-gradient(black, #111111); 4 | background: -o-linear-gradient(black, #111111); 5 | background: linear-gradient(black, #111111); } 6 | 7 | .bg2 { 8 | background: -webkit-linear-gradient(#111111, #222222); 9 | background: -moz-linear-gradient(#111111, #222222); 10 | background: -o-linear-gradient(#111111, #222222); 11 | background: linear-gradient(#111111, #222222); } 12 | /*# sourceMappingURL=sm_update_by_path.css.map */ -------------------------------------------------------------------------------- /test/expected/sm_update_by_path.css.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["../test/fixtures/sm_update.scss"],"names":[],"mappings":"AAAA;EACE,oDAAuC;EAAvC,iDAAuC;EAAvC,+CAAuC;EAAvC,4CAAuC,EAAA;;AAGzC;EACE,sDAAuC;EAAvC,mDAAuC;EAAvC,iDAAuC;EAAvC,8CAAuC,EAAA","file":"sm_update_by_path.css","sourcesContent":[null]} -------------------------------------------------------------------------------- /test/expected/sm_void.css: -------------------------------------------------------------------------------- 1 | .bg1 { 2 | background: -webkit-linear-gradient(black, #111111); 3 | background: -moz-linear-gradient(black, #111111); 4 | background: -o-linear-gradient(black, #111111); 5 | background: linear-gradient(black, #111111); } 6 | 7 | .bg2 { 8 | background: -webkit-linear-gradient(#111111, #222222); 9 | background: -moz-linear-gradient(#111111, #222222); 10 | background: -o-linear-gradient(#111111, #222222); 11 | background: linear-gradient(#111111, #222222); } -------------------------------------------------------------------------------- /test/fixtures/gradient.css: -------------------------------------------------------------------------------- 1 | .test { 2 | background: linear-gradient(#000, #111); 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/sm.css: -------------------------------------------------------------------------------- 1 | .bg1 { 2 | background: linear-gradient(black, #111111); } 3 | 4 | .bg2 { 5 | background: linear-gradient(#111111, #222222); } 6 | -------------------------------------------------------------------------------- /test/fixtures/sm.scss: -------------------------------------------------------------------------------- 1 | .bg1 { 2 | background: linear-gradient(#000, #111); 3 | } 4 | 5 | .bg2 { 6 | background: linear-gradient(#111, #222); 7 | } 8 | -------------------------------------------------------------------------------- /test/fixtures/sm_annotation_path.css: -------------------------------------------------------------------------------- 1 | .bg1 { 2 | background: -webkit-linear-gradient(black, #111111); 3 | background: -moz-linear-gradient(black, #111111); 4 | background: -o-linear-gradient(black, #111111); 5 | background: linear-gradient(black, #111111); } 6 | 7 | .bg2 { 8 | background: -webkit-linear-gradient(#111111, #222222); 9 | background: -moz-linear-gradient(#111111, #222222); 10 | background: -o-linear-gradient(#111111, #222222); 11 | background: linear-gradient(#111111, #222222); } 12 | 13 | /*# sourceMappingURL=sm_update.css.map */ 14 | -------------------------------------------------------------------------------- /test/fixtures/sm_inline_update.css: -------------------------------------------------------------------------------- 1 | .bg1 { 2 | background: linear-gradient(#000000, #111111); 3 | } 4 | .bg2 { 5 | background: linear-gradient(#111111, #222222); 6 | } 7 | /*# sourceMappingURL=data:application/json,%7B%22version%22%3A3%2C%22file%22%3A%22test%2Ffixtures%2Fsm_update_inline.css%22%2C%22sources%22%3A%5B%22sm_inline_update.less%22%5D%2C%22names%22%3A%5B%5D%2C%22mappings%22%3A%22AAAA%3BEACE%2CYAAY%2CiCAAZ%3B%3BAAGF%3BEACE%2CYAAY%2CiCAAZ%22%7D */ 8 | -------------------------------------------------------------------------------- /test/fixtures/sm_inline_update.less: -------------------------------------------------------------------------------- 1 | .bg1 { 2 | background: linear-gradient(#000, #111); 3 | } 4 | 5 | .bg2 { 6 | background: linear-gradient(#111, #222); 7 | } 8 | -------------------------------------------------------------------------------- /test/fixtures/sm_update.css: -------------------------------------------------------------------------------- 1 | .bg1 { 2 | background: linear-gradient(black, #111111); } 3 | 4 | .bg2 { 5 | background: linear-gradient(#111111, #222222); } 6 | 7 | /*# sourceMappingURL=sm_update.css.map */ -------------------------------------------------------------------------------- /test/fixtures/sm_update.css.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "mappings": "AAAA,IAAK;EACH,UAAU,EAAE,+BAA2B;;AAGzC,IAAK;EACH,UAAU,EAAE,iCAA2B", 4 | "sources": ["sm_update.scss"], 5 | "file": "sm_update.css" 6 | } 7 | -------------------------------------------------------------------------------- /test/fixtures/sm_update.scss: -------------------------------------------------------------------------------- 1 | .bg1 { 2 | background: linear-gradient(#000, #111); 3 | } 4 | 5 | .bg2 { 6 | background: linear-gradient(#111, #222); 7 | } 8 | -------------------------------------------------------------------------------- /test/test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var grunt = require('grunt'); 4 | 5 | /* 6 | ======== A Handy Little Nodeunit Reference ======== 7 | https://github.com/caolan/nodeunit 8 | 9 | Test methods: 10 | test.expect(numAssertions) 11 | test.done() 12 | Test assertions: 13 | test.ok(value, [message]) 14 | test.equal(actual, expected, [message]) 15 | test.notEqual(actual, expected, [message]) 16 | test.deepEqual(actual, expected, [message]) 17 | test.notDeepEqual(actual, expected, [message]) 18 | test.strictEqual(actual, expected, [message]) 19 | test.notStrictEqual(actual, expected, [message]) 20 | test.throws(block, [error], [message]) 21 | test.doesNotThrow(block, [error], [message]) 22 | test.ifError(value) 23 | */ 24 | 25 | exports.autoprefixer = { 26 | 27 | setUp: function(done) { 28 | // setup here if necessary 29 | done(); 30 | }, 31 | 32 | single_file: function(test) { 33 | var actual = grunt.file.read('tmp/single_file.css'); 34 | var expected = grunt.file.read('test/expected/gradient.css'); 35 | 36 | test.strictEqual(actual, expected, 'should prefix single file.'); 37 | test.done(); 38 | }, 39 | 40 | multiple_files: function(test) { 41 | var actual = grunt.file.read('tmp/multiple_files/gradient.css'); 42 | var expected = grunt.file.read('test/expected/gradient.css'); 43 | 44 | test.strictEqual(actual, expected, 'should prefix all files.'); 45 | test.done(); 46 | }, 47 | 48 | single_no_dest: function(test) { 49 | var actual = grunt.file.read('tmp/no_dest.css'); 50 | var expected = grunt.file.read('test/expected/gradient.css'); 51 | 52 | test.strictEqual(actual, expected, 'should prefix a source file if target have no destination specified.'); 53 | test.done(); 54 | }, 55 | 56 | no_dest_multiple: function(test) { 57 | var actual = grunt.file.read('tmp/no_dest_multiple/gradient.css'); 58 | var expected = grunt.file.read('test/expected/gradient.css'); 59 | 60 | test.strictEqual(actual, expected, 'should prefix all source files if target have no destination specified.'); 61 | test.done(); 62 | }, 63 | 64 | diff: function(test) { 65 | var actual = grunt.file.read('tmp/diff.css.diff'); 66 | var expected = grunt.file.read('test/expected/diff.css.diff'); 67 | 68 | test.strictEqual(actual, expected, 'should create a diff for a prefixed file.'); 69 | test.done(); 70 | }, 71 | 72 | diff_path: function(test) { 73 | var actual = grunt.file.read('tmp/diff_path.css.diff'); 74 | var expected = grunt.file.read('test/expected/diff_path.css.diff'); 75 | 76 | test.strictEqual(actual, expected, 'should create a diff for a prefixed file and save it to a given path.'); 77 | test.done(); 78 | }, 79 | 80 | sm: function(test) { 81 | var actual = { 82 | css: grunt.file.read('tmp/sm.css'), 83 | map: JSON.parse(grunt.file.read('tmp/sm.css.map')) 84 | }; 85 | 86 | var expected = { 87 | css: grunt.file.read('test/expected/sm.css'), 88 | map: JSON.parse(grunt.file.read('test/expected/sm.css.map')) 89 | }; 90 | 91 | test.strictEqual(actual.css, expected.css, 'should add an annotation comment.'); 92 | test.deepEqual(actual.map, expected.map, 'should generate a new source map.'); 93 | test.done(); 94 | }, 95 | 96 | sm_update: function(test) { 97 | var actual = { 98 | css: grunt.file.read('tmp/sm_update.css'), 99 | map: grunt.file.read('tmp/sm_update.css.map') 100 | }; 101 | 102 | var expected = { 103 | css: grunt.file.read('test/expected/sm_update.css'), 104 | map: grunt.file.read('test/expected/sm_update.css.map') 105 | }; 106 | 107 | test.strictEqual(actual.css, expected.css, 'should leave an annotation comment unchanged.'); 108 | test.deepEqual(actual.map, expected.map, 'should update an existing source map.'); 109 | test.done(); 110 | }, 111 | 112 | sm_update_by_path: function(test) { 113 | var actual = { 114 | css: grunt.file.read('tmp/sm_update_by_path.css'), 115 | map: grunt.file.read('tmp/sm_update_by_path.css.map') 116 | }; 117 | 118 | var expected = { 119 | css: grunt.file.read('test/expected/sm_update_by_path.css'), 120 | map: grunt.file.read('test/expected/sm_update_by_path.css.map') 121 | }; 122 | 123 | test.strictEqual(actual.css, expected.css, 'should leave an annotation comment unchanged.'); 124 | test.deepEqual(actual.map, expected.map, 'should update an existing source map by path.'); 125 | test.done(); 126 | }, 127 | 128 | sm_void: function(test) { 129 | var actual = grunt.file.read('tmp/sm_void.css'); 130 | var expected = grunt.file.read('test/expected/sm_void.css'); 131 | 132 | test.strictEqual(actual, expected, 'shouldn\'t generate a map if the map option is set to `false`.'); 133 | test.ok(grunt.file.exists('tmp/sm_void.css.map') === false); 134 | test.done(); 135 | }, 136 | 137 | sm_inline: function(test) { 138 | var actual = grunt.file.read('tmp/sm_inline.css'); 139 | var expected = grunt.file.read('test/expected/sm_inline.css'); 140 | 141 | test.strictEqual(actual, expected, 'should inline a new source map.'); 142 | test.done(); 143 | }, 144 | 145 | sm_inline_update: function(test) { 146 | var actual = grunt.file.read('tmp/sm_inline_update.css'); 147 | var expected = grunt.file.read('test/expected/sm_inline_update.css'); 148 | 149 | test.strictEqual(actual, expected, 'should update an inlined source map.'); 150 | test.done(); 151 | }, 152 | 153 | sm_annotation_path: function(test) { 154 | var actual = grunt.file.read('tmp/sm_annotation_path.css'); 155 | var expected = grunt.file.read('test/expected/sm_annotation_path.css'); 156 | 157 | test.strictEqual(actual, expected, 'should update sourcemap annotation.'); 158 | test.done(); 159 | } 160 | }; 161 | --------------------------------------------------------------------------------