-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathpurifycss.js
More file actions
41 lines (32 loc) · 1.06 KB
/
purifycss.js
File metadata and controls
41 lines (32 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
* grunt-purifycss
* https://github.com/purifycss/grunt-purify-css
*
* Copyright (c) 2015 Phoebe Li, Matthew Rourke, Kenny Tran
* Licensed under the MIT license.
*/
'use strict';
var glob = require('glob');
var purify = require('purify-css');
module.exports = function(grunt) {
grunt.registerMultiTask('purifycss', 'Clean unnecessary CSS', function() {
// Merge task-specific and/or target-specific options with these defaults.
var options = this.options({
});
var src = [];
this.data.target.src.forEach(function(pathPattern) {
var files = glob.sync(pathPattern);
console.log("Source Files: ", files);
src = src.concat(files);
});
var styles = [];
this.data.target.css.forEach(function(pathPattern) {
var style = glob.sync(pathPattern);
console.log("Style Files: ", style);
styles = styles.concat(style);
});
var pure = purify(src, styles, {write: false, info: true});
grunt.file.write(this.data.target.dest, pure);
grunt.log.writeln('File "' + this.data.dest + '" created.');
});
};