Skip to content
This repository has been archived by the owner on Sep 25, 2020. It is now read-only.

Commit

Permalink
Autoprefixer 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nDmitry committed Nov 14, 2014
1 parent 79ad674 commit e99a162
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 79 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.map]
[{*.css, *.map}]
insert_final_newline = false
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
v2.0.0:
date: 2014-08-23
changes:
- Autoprefixer 4.0
- Maps now inline and containing sourcesContent by default
- New `remove` option to control outdated prefixes cleaning (`true` by default)
v1.0.1:
date: 2014-08-23
changes:
Expand Down
30 changes: 6 additions & 24 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ module.exports = function(grunt) {

sm: {
options: {
map: true
map: {
inline: false
}
},
src: 'test/fixtures/sm.css',
dest: 'tmp/sm.css'
Expand All @@ -98,6 +100,7 @@ module.exports = function(grunt) {
sm_update_by_path: {
options: {
map: {
inline: false,
prev: 'test/fixtures/'
}
},
Expand All @@ -114,39 +117,18 @@ module.exports = function(grunt) {

sm_inline: {
options: {
map: {
inline: true
}
map: true
},
src: 'test/fixtures/sm.css',
dest: 'tmp/sm_inline.css'
},
sm_inline_update: {
options: {
map: {
inline: true
}
map: true
},
src: 'test/fixtures/sm_inline_update.css',
dest: 'tmp/sm_inline_update.css'
},
sm_inline_update_by_path: {
options: {
map: {
prev: 'test/fixtures/',
inline: true
},
},
src: 'test/fixtures/sm_update.css',
dest: 'tmp/sm_inline_update_by_path.css'
},
sm_inline_void: {
options: {
map: false
},
src: 'test/fixtures/sm_inline_update.css',
dest: 'tmp/sm_inline_void.css'
},
log: {
src: 'tmp/single_file.css',
dest: 'tmp/single_file.css'
Expand Down
22 changes: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ Default value: `true`

Pass `false` to disable ‘cascade’ indentation. Read more [here](https://github.com/postcss/autoprefixer#visual-cascade).

#### options.remove
Type: `Boolean`
Default value: `true`

Pass `false` to disable outdated prefixes cleaning. Read more [here](https://github.com/postcss/autoprefixer/releases/tag/4.0.0).

#### options.diff
Type: `Boolean|String`
Default value: `false`
Expand All @@ -79,14 +85,14 @@ Default value: `false`

If the `map` option isn't defined or is set to `false`, Autoprefixer will neither create nor update a sourcemap.

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 sourcemap). The created sourcemap can be either a separate file or an inlined map depending on what the previous sourcemap was.
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.

You can gain more control over sourcemap generation by setting an object to the `map` option:

* `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.
* `inline` (boolean): whether a sourcemap will be inlined or not. By default, it will be the same as a previous sourcemap or a separate file.
* `inline` (boolean): whether a sourcemap will be inlined or not. By default, it will be the same as a previous sourcemap or inlined.
* `annotation` (boolean or string): set this option to `true` or `false` to enable or disable annotation comments. You can also overwrite an output sourcemap path using this option, 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.
* `sourceContent` (boolean): whether original contents (e.g. Sass sources) will be included to a sourcemap. By default, Autoprefixer will add contents only if a previous sourcemap have them.
* `sourceContent` (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.

#### options.silent
Type: `Boolean`
Expand Down Expand Up @@ -147,6 +153,16 @@ grunt.initConfig({
map: true
},
src: 'src/css/file.css',
dest: 'dest/css/file.css' // -> dest/css/file.css, sourcemap is inlined
},

sourcemap_separate: {
options: {
map: {
inline: false
}
},
src: 'src/css/file.css',
dest: 'dest/css/file.css' // -> dest/css/file.css, dest/css/file.css.map
},
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"LICENSE"
],
"dependencies": {
"autoprefixer-core": "^3.0.0",
"autoprefixer-core": "^4.0.0",
"diff": "~1.0.8",
"chalk": "~0.5.0"
},
Expand Down
11 changes: 6 additions & 5 deletions tasks/autoprefixer.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ module.exports = function(grunt) {
return prefixer.process(input, {
map: (typeof options.map === 'boolean') ? options.map : {
prev: getPrevMap(from),
inline: options.map.inline,
annotation: options.map.annotation,
sourcesContent: options.map.sourcesContent
inline: (typeof options.map.inline === 'boolean') ? options.map.inline : true,
annotation: (typeof options.map.annotation === 'boolean') ? options.map.annotation : true,
sourcesContent: (typeof options.map.sourcesContent === 'boolean') ? options.map.sourcesContent : true
},
from: from,
to: to
Expand All @@ -58,10 +58,11 @@ module.exports = function(grunt) {
cascade: true,
diff: false,
map: false,
silent: false
silent: false,
remove: true
});

prefixer = autoprefixer({browsers: options.browsers, cascade: options.cascade});
prefixer = autoprefixer({browsers: options.browsers, cascade: options.cascade, remove: options.remove});

this.files.forEach(function(f) {
if (!f.src.length) {
Expand Down
2 changes: 1 addition & 1 deletion test/expected/sm.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/expected/sm_inline.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions test/expected/sm_inline_update_by_path.css

This file was deleted.

12 changes: 0 additions & 12 deletions test/expected/sm_inline_void.css

This file was deleted.

2 changes: 1 addition & 1 deletion test/expected/sm_update_by_path.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 1 addition & 18 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,22 +148,5 @@ exports.autoprefixer = {

test.strictEqual(actual, expected, 'should update an inlined source map.');
test.done();
},

sm_inline_update_by_path: function(test) {
var actual = grunt.file.read('tmp/sm_inline_update_by_path.css');
var expected = grunt.file.read('test/expected/sm_inline_update_by_path.css');

test.strictEqual(actual, expected, 'should take source map at a specified path, update and inline it.');
test.done();
},

sm_inline_void: function(test) {
var actual = grunt.file.read('tmp/sm_inline_void.css');
var expected = grunt.file.read('test/expected/sm_inline_void.css');

test.strictEqual(actual, expected, 'shouldn\'t inline a map if map option is `false`.');
test.done();
},

}
};

0 comments on commit e99a162

Please sign in to comment.