forked from humhub/humhub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
104 lines (92 loc) · 3.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
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
93
94
95
96
97
98
99
100
101
102
103
104
module.exports = function (grunt) {
var uglifyAssetcfg = {};
uglifyAssetcfg[grunt.option('to')] = grunt.option('from');
var cssMinAssetcfg = {};
cssMinAssetcfg[grunt.option('to')] = [grunt.option('from')];
grunt.log.write(grunt.option('from'));
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
clean: ["assets/*"],
shell: {
buildAssets: {
command: "rm static/js/all-*.js ; rm static/css/all-*.css ; rm -rf static/assets/* ; cd protected ; php yii asset humhub/config/assets.php humhub/config/assets-prod.php"
},
buildSearch: {
command: "cd protected ; php yii search/rebuild"
},
buildTheme: {
command: function(name) {
var theme = name || grunt.option('name') || "HumHub";
return "cd themes/"+theme+"/less ; lessc -x build.less ../css/theme.css";
}
},
migrateCreate: {
command: function(name) {
var migrationName = name || grunt.option('name');
return "cd protected; php yii migrate/create "+migrationName;
}
},
migrateUp: {
command: function(modules) {
var includeModuleMigrations = modules || grunt.option('modules') || "1";
return "cd protected; php yii migrate/up --includeModuleMigrations="+includeModuleMigrations;
}
}
},
uglify: {
build: {
files: {
'js/dist/humhub.all.min.js': ['js/dist/humhub.all.js']
}
},
assets: {
options: {
preserveComments: /^!|@preserve|@license|@cc_on/i
},
files: uglifyAssetcfg
}
},
cssmin: {
target: {
files: cssMinAssetcfg
}
},
less: {
dev: {
files: {
'themes/HumHub/css/less/theme.css': 'themes/HumHub/css/less/theme.less'
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-shell');
//grunt.registerTask('default', ['watch']);
grunt.registerTask('build-assets', ['shell:buildAssets']);
grunt.registerTask('build-search', ['shell:buildSearch']);
grunt.registerTask('migrate-up', ['shell:migrateUp']);
/**
* Will create a new migration into the protected/humhub/migrations directory
*
* > grunt migrate-create --name=MyMigration
*/
grunt.registerTask('migrate-create', ['shell:migrateCreate']);
/**
* Build default HumHub theme:
*
* > grunt build-theme
*
* Build named theme:
* > grunt build-theme --name=MyTheme
*
* or
*
* > grunt shell:buildTheme:MyTheme
*/
grunt.registerTask('build-theme', ['shell:buildTheme']);
};