Skip to content
This repository was archived by the owner on Dec 19, 2024. It is now read-only.

First pass at integrating postcss-url into cssnext #62

Merged
merged 1 commit into from
Jan 28, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var assign = require("object-assign")
var features = {
// Reminder: order is important
import: function(options) { return require("postcss-import")(options) },
url: function(options) { return require("postcss-url")(options) },
customProperties: function(options) { return require("postcss-custom-properties")(options) },
calc: function(options) { return require("postcss-calc")(options)},
customMedia: function(options) { return require("postcss-custom-media")(options)},
Expand Down Expand Up @@ -60,7 +61,7 @@ function cssnext(string, options) {
var postcss = Postcss()

Object.keys(cssnext.features).forEach(function(key) {
// if undefined, we use consider feature is wanted (default behavior)
// if undefined, we default to assuming this feature is wanted by the user
if (features[key] !== false) {
postcss.use(cssnext.features[key](typeof features[key] === "object" ? features[key] : undefined))
}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"postcss-font-variant": "^1.0.0",
"postcss-import": "^5.0.0",
"postcss-media-minmax": "^1.1.0",
"postcss-url": "^2.0.0",
"read-file-stdin": "^0.2.0",
"to-slug-case": "^0.1.2",
"to-space-case": "^0.1.3",
Expand Down
12 changes: 9 additions & 3 deletions test/features.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,14 @@ var testFeature = function(t, feature, cssnext, version, source, input, expected
t.notEqual(css, expected, version + ": should not add " + feature + " support if disabled")
t.equal(css, input, version + ": should not modify input if " + feature + " is disabled")

// enable only the one we want to test
// enable only the one we want to test...
options.features[feature] = true

// ...except "url" because we want to validate its behaviour when integrated
// with "import"
if (feature === "url") {
options.features["import"] = true
}
t.equal(cssnext(input, options).trim(), expected.trim(), version + ": should add " + feature + " support")
}

Expand All @@ -35,8 +41,8 @@ Object.keys(cssnext.features).forEach(function(name) {
test(slug, function(t) {
testFeature(t, name, cssnext, "node.js", source, input, expected)

// we do not support @import in the browser
if ("import" === name) {
// we do not support @import or url rewriting in the browser
if ("import" === name || "url" === name) {
t.end()
return
}
Expand Down
1 change: 1 addition & 0 deletions test/features/url.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import './url/dependency'
4 changes: 4 additions & 0 deletions test/features/url.expected.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@font-face {
name: 'url-font';
src: url('url/assets/source-sans-regular.woff')
}
Binary file added test/features/url/assets/source-sans-regular.woff
Binary file not shown.
4 changes: 4 additions & 0 deletions test/features/url/dependency.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@font-face {
name: 'url-font';
src: url('./assets/source-sans-regular.woff');
}