-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'autoprefixer'. Closes #64
* autoprefixer: Added autoprefixer transform to buildProduction transform and binary Added autoprefixer transform Added test scaffold Aded autoprefixer to package.json
- Loading branch information
Showing
12 changed files
with
626 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* autoprefixer transform | ||
* | ||
* - Runs autoprefixer with the supplied options on each css asset | ||
* - Removes all references to prefixfree | ||
*/ | ||
|
||
var autoprefix = require('autoprefixer'); | ||
|
||
module.exports = function (options) { | ||
// See https://github.com/ai/autoprefixer#browsers | ||
var browsers = options; | ||
|
||
return function autoprefixer(assetGraph) { | ||
assetGraph.findAssets({type: 'Css'}).forEach(function (cssAsset) { | ||
cssAsset.text = autoprefix(browsers).process(cssAsset.text).css; | ||
}); | ||
|
||
assetGraph.findRelations({ | ||
to: { | ||
fileName: /prefixfree(\.min)?\.js/ | ||
} | ||
}).forEach(function (relation) { | ||
relation.remove(); | ||
}); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
var vows = require('vows'), | ||
assert = require('assert'), | ||
AssetGraph = require('../lib/AssetGraph'); | ||
|
||
vows.describe('transforms.autoprefixer').addBatch({ | ||
'After loading an unprefixed test case': { | ||
topic: function () { | ||
new AssetGraph({root: __dirname + '/autoprefixer/'}) | ||
.loadAssets('index.html') | ||
.populate() | ||
.run(this.callback); | ||
}, | ||
'the graph should contain 2 HtmlStyle relations': function (assetGraph) { | ||
assert.equal(assetGraph.findRelations({type: 'HtmlStyle'}).length, 2); | ||
}, | ||
'the graph should contain 1 CssImage relation': function (assetGraph) { | ||
assert.equal(assetGraph.findRelations({type: 'CssImage'}).length, 1); | ||
}, | ||
'then running the autoprefixer transform': { | ||
topic: function (assetGraph) { | ||
assetGraph | ||
.autoprefixer() | ||
.run(this.callback); | ||
}, | ||
'the graph should contain 2 HtmlStyle relations': function (assetGraph) { | ||
assert.equal(assetGraph.findRelations({type: 'HtmlStyle'}).length, 2); | ||
}, | ||
'the graph should contain 3 CssImage relation': function (assetGraph) { | ||
assert.equal(assetGraph.findRelations({type: 'CssImage'}).length, 3); | ||
} | ||
} | ||
}, | ||
'After loading an test case using prefixfree.js': { | ||
topic: function () { | ||
new AssetGraph({root: __dirname + '/autoprefixer/'}) | ||
.loadAssets('prefixfree.html') | ||
.populate() | ||
.run(this.callback); | ||
}, | ||
'the graph should contain 2 HtmlScript relations': function (assetGraph) { | ||
assert.equal(assetGraph.findRelations({type: 'HtmlScript'}).length, 2); | ||
}, | ||
'then running the autoprefixer transform': { | ||
topic: function (assetGraph) { | ||
assetGraph | ||
.autoprefixer() | ||
.run(this.callback); | ||
}, | ||
'the graph should contain 0 HtmlScript relations': function (assetGraph) { | ||
assert.equal(assetGraph.findRelations({type: 'HtmlScript'}).length, 0); | ||
} | ||
} | ||
} | ||
|
||
})['export'](module); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
body { | ||
border-image: url(borderimage.png) 30 30 repeat; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Document</title> | ||
<link rel="stylesheet" type="text/css" href="userselect.css"> | ||
<link rel="stylesheet" type="text/css" href="borderimage.css"> | ||
</head> | ||
<body> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Document</title> | ||
|
||
<script src="prefixfree.js"></script> | ||
<script src="prefixfree.min.js"></script> | ||
</head> | ||
<body> | ||
|
||
</body> | ||
</html> |
Oops, something went wrong.