forked from DecentCMS/DecentCMS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
92 lines (84 loc) · 2.42 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
81
82
83
84
85
86
87
88
89
90
91
92
// DecentCMS (c) 2014 Bertrand Le Roy, under MIT. See LICENSE.txt for licensing details.
'use strict';
var buildConfig = require('./lib/sub-grunt-config').buildConfig;
var buildInstallConfig = require('./lib/sub-grunt-config').buildInstallConfig;
module.exports = function gruntDecent(grunt) {
grunt.initConfig();
// Execution of Grunt tasks in each module and theme
grunt.loadNpmTasks('grunt-run-grunt');
var verbose = grunt.option('verbose');
var runGruntConfig = {};
var runTasks = buildConfig('run_grunt', 'default', runGruntConfig, verbose);
var testTasks = buildConfig('run_grunt', 'test', runGruntConfig, verbose);
grunt.config.merge({
run_grunt: runGruntConfig
});
// console.log(JSON.stringify(runGruntConfig, null, 2));
grunt.registerTask(
'modules',
'Run all tasks in all modules.',
runTasks);
grunt.registerTask(
'test',
'Run all tests in all modules.',
testTasks
);
// Installation and update of all modules and themes' dependencies
var installTask = require('./lib/grunt-install-decent-modules');
installTask(grunt);
grunt.config.merge({
install_decent_modules: {
all: {
npmCommand: 'install',
dependencies: true,
devDependencies: true
},
update_all: {
npmCommand: 'update',
dependencies: true,
devDependencies: true
},
install_runtime: {
npmCommand: 'install',
dependencies: true,
devDependencies: false
}
}
});
grunt.registerTask(
'install',
'Install all dependencies of all modules and themes.',
['install_decent_modules:all']
);
grunt.registerTask(
'update',
'Update all dependencies of all modules and themes.',
['install_decent_modules:update_all']
);
grunt.registerTask(
'install_runtime',
'Install only runtime dependencies (not dev dependencies) of all modules and themes.',
['install_decent_modules:install_runtime']
);
// Other top-level Grunt tasks
// Image minification
grunt.loadNpmTasks('grunt-contrib-imagemin');
grunt.config.merge({
imagemin: {
all: {
options: {
optimizationLevel: 7,
progressive: true
},
files: [
{
expand: true,
cwd: './',
src: ['**/img/*.{png,jpg,gif,svg}']
}
]
}
}
});
grunt.registerTask('images', 'Minimize all images in all folders', 'imagemin');
};