Skip to content

Commit

Permalink
Remove annotation from preprocess step
Browse files Browse the repository at this point in the history
  • Loading branch information
iamvdo committed Mar 30, 2015
1 parent d2dfa82 commit f14e0d6
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 14 deletions.
3 changes: 3 additions & 0 deletions lib/options.js
Expand Up @@ -215,6 +215,7 @@ Options.prototype.setSourcemaps = function (opts) {
}
opts.sass.sourceMap = true;
opts.sass.sourceMapEmbed = false;
opts.sass.omitSourceMapUrl = true;
}
if (opts.less) {
if (opts.less === true) {
Expand All @@ -226,6 +227,7 @@ Options.prototype.setSourcemaps = function (opts) {
}
opts.less.sourceMap = opts.less.sourceMap || {};
opts.less.sourceMap.sourceMapFileInline = false;
opts.less.sourceMap.sourceMapURL = false;
}
if (opts.stylus) {
if (opts.stylus === true) {
Expand All @@ -237,6 +239,7 @@ Options.prototype.setSourcemaps = function (opts) {
}
opts.stylus.sourcemap = opts.stylus.sourcemap || {};
opts.stylus.sourcemap.inline = false;
opts.stylus.sourcemap.comment = false;
}
}
}
Expand Down
1 change: 0 additions & 1 deletion lib/preprocessor.js
Expand Up @@ -52,7 +52,6 @@ Preprocessor.prototype.less = function () {
// set specific options
if (this.sourcemaps) {
opts.filename = this.sourcemaps.from;
opts.sourceMap.sourceMapFilename = this.sourcemaps.from;
opts.sourceMap.sourceMapOutputFilename = this.sourcemaps.to;
// get basepath and rootpath
var from = path.resolve(this.sourcemaps.from);
Expand Down
34 changes: 34 additions & 0 deletions test/preprocessor.js
Expand Up @@ -2,6 +2,7 @@

var pleeease = require('../lib/pleeease');
var fs = require('fs');
var Preprocessor = require('../lib/preprocessor');

var dirname = 'test/preprocessors/';

Expand All @@ -19,6 +20,39 @@ describe('Preprocessor', function () {
opts.minifier = true;
});

describe('#sass', function () {

it('doesn\'t add annotation', function () {
var p = new pleeease({sass: true, sourcemaps: true});
var pre = new Preprocessor('a{a:a}', p.options);
var result = pre.sass();
result.css.should.not.containEql('sourceMappingURL=');
});

});

describe('#less', function () {

it('doesn\'t add annotation', function () {
var p = new pleeease({less: true, sourcemaps: true});
var pre = new Preprocessor('a{a:a}', p.options);
var result = pre.less();
result.css.should.not.containEql('sourceMappingURL=');
});

});

describe('#stylus', function () {

it('doesn\'t add annotation', function () {
var p = new pleeease({stylus: true, sourcemaps: true});
var pre = new Preprocessor('a{a:a}', p.options);
var result = pre.stylus();
result.css.should.not.containEql('sourceMappingURL=');
});

});

describe('Processes plain ol\' CSS', function () {

var css, expected, processed;
Expand Down
53 changes: 40 additions & 13 deletions test/sourcemaps.js
Expand Up @@ -369,21 +369,48 @@ describe('Sourcemaps', function () {

var dirname = 'test/preprocessors/';

it('adds annotations with preprocessors', function () {
opts.sourcemaps = {map: {inline: false}};
opts.sass = true;
var processed = pleeease.process('a{a:a}', opts);
processed.css.should.containEql('sourceMappingURL=');
describe('adds annotation', function () {

opts.sass = false;
opts.less = true;
processed = pleeease.process('a{a:a}', opts);
processed.css.should.containEql('sourceMappingURL=');
beforeEach(function () {
opts.sourcemaps = {map: {inline: false}};
});
afterEach(function () {
var processed = pleeease.process('a{a:a}', opts);
processed.css.should.containEql('sourceMappingURL=');
});

it('with Sass', function () {
opts.sass = true;
});
it('with LESS', function () {
opts.less = true;
});
it('with Stylus', function () {
opts.stylus = true;
});

});

describe('adds annotation only once', function () {

beforeEach(function () {
opts.sourcemaps = {map: {inline: false}};
});
afterEach(function () {
var processed = pleeease.process('a{a:a}', opts);
processed.css.match(/sourceMappingURL=/g).length.should.eql(1);
});

it('with Sass', function () {
opts.sass = true;
});
it('with LESS', function () {
opts.less = true;
});
it('with Stylus', function () {
opts.stylus = true;
});

opts.sass = opts.less = false;
opts.stylus = true;
processed = pleeease.process('a{a:a}', opts);
processed.css.should.containEql('sourceMappingURL=');
});

describe('generates good sourcemaps', function () {
Expand Down

0 comments on commit f14e0d6

Please sign in to comment.