2016-03-24 02:03:42 +01:00
|
|
|
module.exports = function (grunt) {
|
2016-05-02 21:40:26 +02:00
|
|
|
|
2017-03-17 13:48:08 +01:00
|
|
|
|
|
|
|
|
2016-08-21 19:58:55 +02:00
|
|
|
var uglifyAssetcfg = {};
|
|
|
|
uglifyAssetcfg[grunt.option('to')] = grunt.option('from');
|
2017-03-17 13:48:08 +01:00
|
|
|
|
2016-08-21 19:58:55 +02:00
|
|
|
var cssMinAssetcfg = {};
|
|
|
|
cssMinAssetcfg[grunt.option('to')] = [grunt.option('from')];
|
|
|
|
|
|
|
|
grunt.log.write(grunt.option('from'));
|
2016-08-23 22:29:34 +02:00
|
|
|
|
2016-03-24 02:03:42 +01:00
|
|
|
grunt.initConfig({
|
2016-08-21 19:58:55 +02:00
|
|
|
pkg: grunt.file.readJSON('package.json'),
|
2017-03-17 13:48:08 +01:00
|
|
|
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"
|
2016-05-02 21:40:26 +02:00
|
|
|
},
|
2017-03-17 13:48:08 +01:00
|
|
|
buildSearch: {
|
|
|
|
command: "cd protected ; php yii search/rebuild"
|
|
|
|
},
|
|
|
|
buildTheme: {
|
|
|
|
command: function(name) {
|
2017-05-10 11:42:36 +02:00
|
|
|
var theme = name || grunt.option('name') || "HumHub";
|
2017-03-17 13:48:08 +01:00
|
|
|
return "cd themes/"+theme+"/less ; lessc -x build.less ../css/theme.css";
|
|
|
|
}
|
2017-05-10 11:42:36 +02:00
|
|
|
},
|
|
|
|
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;
|
|
|
|
}
|
2016-03-24 02:03:42 +01:00
|
|
|
}
|
2017-03-17 13:48:08 +01:00
|
|
|
|
2016-03-24 02:03:42 +01:00
|
|
|
},
|
2016-04-19 15:47:05 +02:00
|
|
|
uglify: {
|
|
|
|
build: {
|
|
|
|
files: {
|
2016-05-02 21:40:26 +02:00
|
|
|
'js/dist/humhub.all.min.js': ['js/dist/humhub.all.js']
|
|
|
|
}
|
2016-08-21 19:58:55 +02:00
|
|
|
},
|
|
|
|
assets: {
|
2016-08-23 22:29:34 +02:00
|
|
|
options: {
|
2017-03-17 13:48:08 +01:00
|
|
|
preserveComments: /^!|@preserve|@license|@cc_on/i
|
2016-08-23 22:29:34 +02:00
|
|
|
},
|
2016-08-21 19:58:55 +02:00
|
|
|
files: uglifyAssetcfg
|
|
|
|
}
|
|
|
|
},
|
|
|
|
cssmin: {
|
|
|
|
target: {
|
|
|
|
files: cssMinAssetcfg
|
2016-05-02 21:40:26 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
less: {
|
|
|
|
dev: {
|
|
|
|
files: {
|
|
|
|
'themes/HumHub/css/less/theme.css': 'themes/HumHub/css/less/theme.less'
|
2016-04-19 15:47:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-03-24 02:03:42 +01:00
|
|
|
});
|
2017-03-17 13:48:08 +01:00
|
|
|
|
2016-05-02 21:40:26 +02:00
|
|
|
grunt.loadNpmTasks('grunt-contrib-less');
|
2016-03-24 02:03:42 +01:00
|
|
|
grunt.loadNpmTasks('grunt-contrib-concat');
|
2016-04-19 15:47:05 +02:00
|
|
|
grunt.loadNpmTasks('grunt-contrib-uglify');
|
2016-08-21 19:58:55 +02:00
|
|
|
grunt.loadNpmTasks('grunt-contrib-cssmin');
|
2016-03-24 02:03:42 +01:00
|
|
|
grunt.loadNpmTasks('grunt-contrib-watch');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-clean');
|
2017-03-17 13:48:08 +01:00
|
|
|
grunt.loadNpmTasks('grunt-shell');
|
|
|
|
|
|
|
|
//grunt.registerTask('default', ['watch']);
|
|
|
|
grunt.registerTask('build-assets', ['shell:buildAssets']);
|
|
|
|
grunt.registerTask('build-search', ['shell:buildSearch']);
|
2017-05-10 11:42:36 +02:00
|
|
|
|
|
|
|
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']);
|
2017-03-17 13:48:08 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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']);
|
2016-04-19 15:47:05 +02:00
|
|
|
};
|