-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
80 lines (66 loc) · 1.98 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
const fs = require('fs');
const path = require('path');
const initConfig = require('./grunt/initConfig');
const config = JSON.parse(fs.readFileSync(path.resolve('grunt.json')));
module.exports = function (grunt) {
let tasks = [
'setup'
];
require('./grunt/getFileTypes')(function (types) {
initConfig.pkg = grunt.file.readJSON('package.json');
grunt.initConfig(initConfig);
tasks.push(
'readme',
'flatman'
);
if (types.img.length) {
if (config.isProduction) {
grunt.loadNpmTasks('grunt-contrib-imagemin');
tasks.push('imagemin');
} else {
tasks.push('copy:images');
}
}
if (types.svg.length) {
grunt.loadNpmTasks('grunt-svgstore');
tasks.push('svgstore');
}
if (types.sass.length) {
tasks.push('sass');
tasks.push('autoprefixer');
grunt.loadNpmTasks('grunt-autoprefixer');
grunt.loadNpmTasks('grunt-contrib-sass');
if (config.isProduction) {
grunt.loadNpmTasks('grunt-contrib-cssmin');
}
}
if (config.ignore && !config.ignore.includes('javascript')) {
if (types.js && config.isProduction) {
grunt.loadNpmTasks('grunt-contrib-uglify');
tasks.push('uglify');
} else {
grunt.loadNpmTasks('grunt-contrib-concat');
tasks.push('concat');
}
}
tasks.push('test');
grunt.registerTask('setup', function () {
require('./grunt/setup')(this.async());
});
grunt.registerTask('flatman', function () {
require('./grunt/flatman').task(this.async());
});
grunt.registerTask('readme', function () {
require('./grunt/readme').task(this.async());
});
grunt.registerTask('test', function () {
require('./grunt/test').task(this.async());
});
if (!config.isProduction) {
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-watch');
tasks.push('watch');
}
grunt.registerTask('default', tasks);
});
};