Skip to content
Browse files

Merge pull request #7 from corpix/moar-settings

Stylus defines with tests, compress option
  • Loading branch information...
2 parents 6c9403c + 7f7926b commit eaf13a8144baaf5480284c2e5858cb0b71feac1c @paulmillr paulmillr committed
Showing with 24 additions and 6 deletions.
  1. +1 −1 package.json
  2. +10 −1 src/index.coffee
  3. +13 −4 test/plugin_test.js
  4. BIN test/support/img/dot.jpg
View
2 package.json
@@ -1,6 +1,6 @@
{
"name": "stylus-brunch",
- "version": "1.3.1",
+ "version": "1.3.2",
"description": "Adds Stylus support to brunch.",
"author": "Paul Miller (http://paulmillr.com/)",
"homepage": "https://github.com/brunch/stylus-brunch",
View
11 src/index.coffee
@@ -23,7 +23,16 @@ module.exports = class StylusCompiler
.include(sysPath.join @config.paths.root)
.include(sysPath.dirname path)
.use(nib())
- @config.stylus?.paths?.forEach (path) -> compiler.include(path)
+
+
+ if @config.stylus
+ # Defines
+ defines = @config.stylus.defines ? {}
+ Object.keys(defines).forEach (name) -> compiler.define name, defines[name]
+
+ # Paths
+ @config.stylus.paths?.forEach (path) -> compiler.include(path)
+
compiler.render(callback)
getDependencies: (data, path, callback) =>
View
17 test/plugin_test.js
@@ -1,17 +1,21 @@
+var fs = require('fs');
var sysPath = require('path');
var supportPath = sysPath.resolve(__dirname, 'support');
describe('Plugin', function() {
var plugin;
var fileName = 'app/styles/style.styl';
-
+
beforeEach(function() {
plugin = new Plugin({
paths: {
root: ''
},
stylus: {
- paths: [supportPath]
+ paths: [supportPath],
+ defines: {
+ url: require('stylus').url()
+ }
}
});
});
@@ -26,8 +30,13 @@ describe('Plugin', function() {
});
it('should compile and produce valid result', function(done) {
- var content = 'body\n font: 12px Helvetica, Arial, sans-serif';
- var expected = 'body {\n font: 12px Helvetica, Arial, sans-serif;\n}\n';
+ var urlTest = {
+ imagePath: 'img/dot.jpg'
+ }
+
+ urlTest.base64 = fs.readFileSync(supportPath + '/' + urlTest.imagePath).toString('base64');
+ var content = 'body\n font: 12px Helvetica, Arial, sans-serif\n background: url("' + urlTest.imagePath + '")';
+ var expected = 'body {\n font: 12px Helvetica, Arial, sans-serif;\n background: url("data:image/jpeg;base64,' + urlTest.base64 + '");\n}\n';
plugin.compile(content, fileName, function(error, data) {
expect(error).to.equal(null);
View
BIN test/support/img/dot.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit eaf13a8

Please sign in to comment.
Something went wrong with that request. Please try again.