-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGruntfile.js
56 lines (50 loc) · 1.28 KB
/
Gruntfile.js
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//const path = require('path');
module.exports = function(grunt)
{
grunt.registerTask('default', 'sass',
function()
{
grunt.log.writeln('start');
//run async tasks
let done = this.async();
for(let x of scssMinTask(done))
{
grunt.log.writeln(JSON.stringify(x));
}
});
};
function* scssMinTask(done)
{
const globby = require('globby');
const concat = require('concat');
const sass = require('node-sass');
const CleanCSS = require('clean-css');
const fs = require('fs');
let concated,complied,output,inputPaths;
yield inputPaths = globby(['./scr/sass/*'])
.then((paths)=>{return paths})
.catch((err)=>
{
obj = {error:err,subtask:'globby'};
return obj;
});
yield concated = concat(inputPaths)
.then((result)=>{return result;})
.catch((err) =>
{
obj = {error:err,subtask:'concat sass'};
return obj;
});
yield complied = sass.renderSync({data: concated});
yield output = new CleanCSS({}).minify(complied.css);
fs.writeFile('./public/stylesheets/style.css', ouput.styles,
function (err)
{
if (err)
{
obj = {error:err,subtask:'fs'};
return obj;
};
done();
});
}