browserify-css
Advanced tools
Comparing version 0.9.0 to 0.9.1
@@ -108,2 +108,10 @@ 'use strict'; | ||
var processRule = function (rule) { | ||
if (rebaseUrls) { | ||
_.each(rule.declarations, function(declaration) { | ||
declaration.value = rebase(declaration.value); | ||
}); | ||
} | ||
}; | ||
var data = fs.readFileSync(filename, 'utf8'); | ||
@@ -165,6 +173,8 @@ if ( ! data) { | ||
} else { | ||
if (rebaseUrls) { | ||
_.each(rule.declarations, function(declaration) { | ||
declaration.value = rebase(declaration.value); | ||
}); | ||
if (rule.type === 'media') { | ||
// handle rules in media query | ||
_.each(rule.rules, processRule); | ||
} else { | ||
// handle normal rules | ||
processRule(rule); | ||
} | ||
@@ -188,2 +198,5 @@ | ||
var defaults = { | ||
rebaseUrls: true, | ||
rootDir: process.cwd(), | ||
processRelativeUrl: null | ||
}; | ||
@@ -190,0 +203,0 @@ |
@@ -71,3 +71,3 @@ var _ = require('lodash'); | ||
return url; | ||
return relativeUrl; | ||
} | ||
@@ -74,0 +74,0 @@ } |
@@ -19,3 +19,2 @@ 'use strict'; | ||
}, | ||
rebaseUrls: true, | ||
rootDir: process.cwd(), | ||
@@ -46,3 +45,3 @@ onFlush: function(options, done) { | ||
options = _.extend({}, options, opts); | ||
options = _.merge({}, options, opts); | ||
@@ -49,0 +48,0 @@ return through( |
{ | ||
"name": "browserify-css", | ||
"version": "0.9.0", | ||
"version": "0.9.1", | ||
"description": "A Browserify transform for bundling, rebasing, inlining, and minifying CSS files", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
'use strict'; | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var test = require('tap').test; | ||
@@ -52,1 +53,18 @@ var browserify = require('browserify'); | ||
}); | ||
test('processRelativeUrl with media query', function(t) { | ||
var cssTransform = require('../css-transform'); | ||
var inputFile = path.resolve(__dirname, 'fixtures/app.css'); | ||
var outputFile = path.resolve(__dirname, 'fixtures/app.output.css'); | ||
cssTransform({ | ||
rootDir: path.resolve(__dirname, 'fixtures'), | ||
rebaseUrls: true, | ||
processRelativeUrl: function(relativeUrl) { | ||
return 'images/' + relativeUrl; | ||
} | ||
}, inputFile, function(data) { | ||
t.same(data, fs.readFileSync(outputFile, 'utf-8')); | ||
t.end(); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2245759
72
20286