Skip to content

Commit

Permalink
Allowing to pass options to css nano
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio-Laguna committed Jan 11, 2018
1 parent 321925c commit a1c2ead
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 2 deletions.
7 changes: 6 additions & 1 deletion css.js
Expand Up @@ -182,7 +182,12 @@ class CSSTask extends TaskKitTask {

// minify if specified in config files:
if (this.options.minify) {
processes.push(cssnano({ zindex: false }));
const options = this.options.minifyOptions || {
zindex: false,
reduceIdents: false
};

processes.push(cssnano(options));
}
async.autoInject({
contents: (done) => {
Expand Down
2 changes: 2 additions & 0 deletions test/expected/minify-options.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/expected/minify.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions test/fixtures/minify-options.css
@@ -0,0 +1,11 @@
@keyframes fadeOut {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
.box {
animation-name: fadeOut;
}
12 changes: 12 additions & 0 deletions test/fixtures/minify.css
@@ -1,3 +1,15 @@
@keyframes fadeOut {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
.box {
animation-name: fadeOut;
}

body {
background: red;
}
21 changes: 21 additions & 0 deletions test/minify-options.test.js
@@ -0,0 +1,21 @@
const tap = require('tap');
const ClientKitCss = require('../');
const utils = require('./utils');

tap.test('minify options', (t) => {
const css = new ClientKitCss('minify', {
files: {
'test/out/minify-options.css': 'test/fixtures/minify-options.css'
},
minify: true,
minifyOptions: {
zindex: false,
reduceIdents: true
}
});
css.execute((err, results) => {
t.equal(err, null);
utils.checkOutput(t, 'minify-options.css');
t.end();
});
});

0 comments on commit a1c2ead

Please sign in to comment.