2013-09-06 17:19:43 +00:00
|
|
|
/*global module:false*/
|
2013-11-04 21:11:45 +00:00
|
|
|
var _ = require('lodash');
|
2013-09-06 17:19:43 +00:00
|
|
|
module.exports = function(grunt) {
|
|
|
|
|
|
|
|
|
|
// Project configuration.
|
|
|
|
|
grunt.initConfig({
|
2014-02-14 17:35:21 +00:00
|
|
|
pkg: grunt.file.readJSON('package.json'),
|
|
|
|
|
|
2014-01-16 08:10:00 +00:00
|
|
|
git_changelog: {
|
|
|
|
|
minimal: {
|
|
|
|
|
options: {
|
|
|
|
|
repo_url: 'https://github.com/habitrpg/habitrpg',
|
|
|
|
|
appName : 'HabitRPG',
|
|
|
|
|
branch_name: 'develop'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
extended: {
|
|
|
|
|
options: {
|
|
|
|
|
file: 'EXTENDEDCHANGELOG.md',
|
|
|
|
|
repo_url: 'https://github.com/habitrpg/habitrpg',
|
|
|
|
|
appName : 'HabitRPG',
|
|
|
|
|
branch_name: 'develop',
|
2014-01-17 18:25:36 +00:00
|
|
|
grep_commits: '^perf|^style|^fix|^feat|^docs|^refactor|^chore|BREAKING'
|
2014-01-16 08:10:00 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2013-09-06 17:19:43 +00:00
|
|
|
|
2013-09-14 01:19:02 +00:00
|
|
|
karma: {
|
|
|
|
|
unit: {
|
|
|
|
|
configFile: 'karma.conf.js'
|
2013-11-01 01:45:10 +00:00
|
|
|
},
|
|
|
|
|
continuous: {
|
|
|
|
|
configFile: 'karma.conf.js',
|
|
|
|
|
singleRun: true,
|
|
|
|
|
autoWatch: false
|
2013-09-14 01:19:02 +00:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2013-09-06 17:19:43 +00:00
|
|
|
clean: {
|
2013-09-10 10:39:17 +00:00
|
|
|
build: ['build']
|
2013-09-06 17:19:43 +00:00
|
|
|
},
|
|
|
|
|
|
2013-09-06 19:39:18 +00:00
|
|
|
stylus: {
|
|
|
|
|
build: {
|
|
|
|
|
options: {
|
|
|
|
|
compress: false, // AFTER
|
|
|
|
|
'include css': true,
|
|
|
|
|
paths: ['public']
|
|
|
|
|
},
|
|
|
|
|
files: {
|
2013-09-10 10:29:43 +00:00
|
|
|
'build/app.css': ['public/css/index.styl'],
|
|
|
|
|
'build/static.css': ['public/css/static.styl']
|
2013-09-06 19:39:18 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2013-09-10 12:40:00 +00:00
|
|
|
copy: {
|
|
|
|
|
build: {
|
2014-01-07 19:23:39 +00:00
|
|
|
files: [
|
|
|
|
|
{expand: true, cwd: 'public/', src: 'favicon.ico', dest: 'build/'},
|
2015-01-29 16:59:30 +00:00
|
|
|
{expand: true, cwd: 'public/', src: 'bower_components/habitrpg-shared/dist/spritesmith*.png', dest: 'build/'},
|
2014-02-12 17:08:17 +00:00
|
|
|
{expand: true, cwd: 'public/', src: 'bower_components/habitrpg-shared/img/sprites/backer-only/*.gif', dest: 'build/'},
|
|
|
|
|
{expand: true, cwd: 'public/', src: 'bower_components/habitrpg-shared/img/sprites/npc_ian.gif', dest: 'build/'},
|
2014-02-12 14:10:22 +00:00
|
|
|
{expand: true, cwd: 'public/', src: 'bower_components/bootstrap/dist/fonts/*', dest: 'build/'}
|
2014-01-07 19:23:39 +00:00
|
|
|
]
|
2013-09-10 12:40:00 +00:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2013-09-10 12:43:30 +00:00
|
|
|
// UPDATE IT WHEN YOU ADD SOME FILES NOT ALREADY MATCHED!
|
2013-09-10 10:39:17 +00:00
|
|
|
hashres: {
|
|
|
|
|
build: {
|
|
|
|
|
options: {
|
|
|
|
|
fileNameFormat: '${name}-${hash}.${ext}'
|
|
|
|
|
},
|
|
|
|
|
src: [
|
2013-09-10 12:40:00 +00:00
|
|
|
'build/*.js', 'build/*.css', 'build/favicon.ico',
|
2014-02-12 14:10:22 +00:00
|
|
|
'build/bower_components/habitrpg-shared/dist/*.png',
|
2014-02-12 17:08:17 +00:00
|
|
|
'build/bower_components/habitrpg-shared/img/sprites/backer-only/*.gif',
|
|
|
|
|
'build/bower_components/habitrpg-shared/img/sprites/npc_ian.gif',
|
2014-02-12 14:10:22 +00:00
|
|
|
'build/bower_components/bootstrap/dist/fonts/*'
|
2013-09-10 10:39:17 +00:00
|
|
|
],
|
2014-02-12 14:10:22 +00:00
|
|
|
dest: 'build/*.css'
|
2013-09-10 10:39:17 +00:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2014-02-14 17:35:21 +00:00
|
|
|
nodemon: {
|
|
|
|
|
dev: {
|
|
|
|
|
script: '<%= pkg.main %>'
|
|
|
|
|
}
|
|
|
|
|
},
|
2013-09-07 10:47:44 +00:00
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
|
dev: {
|
2013-09-10 20:57:34 +00:00
|
|
|
files: ['public/**/*.styl'], // 'public/**/*.js' Not needed because not in production
|
2013-09-07 10:47:44 +00:00
|
|
|
tasks: [ 'build:dev' ],
|
|
|
|
|
options: {
|
|
|
|
|
nospawn: true
|
2013-09-06 20:33:00 +00:00
|
|
|
}
|
|
|
|
|
}
|
2013-09-07 10:47:44 +00:00
|
|
|
},
|
2013-09-06 19:39:18 +00:00
|
|
|
|
2013-09-07 10:47:44 +00:00
|
|
|
concurrent: {
|
|
|
|
|
dev: ['nodemon', 'watch'],
|
2013-09-06 17:19:43 +00:00
|
|
|
options: {
|
2013-09-07 10:47:44 +00:00
|
|
|
logConcurrentOutput: true
|
2013-09-06 17:19:43 +00:00
|
|
|
}
|
2013-09-07 10:47:44 +00:00
|
|
|
}
|
2013-09-06 17:19:43 +00:00
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
2013-11-04 21:11:45 +00:00
|
|
|
//Load build files from public/manifest.json
|
|
|
|
|
grunt.registerTask('loadManifestFiles', 'Load all build files from public/manifest.json', function(){
|
2015-02-05 17:20:40 +00:00
|
|
|
var files = grunt.file.readJSON('./website/public/manifest.json');
|
2013-11-04 21:11:45 +00:00
|
|
|
var uglify = {};
|
|
|
|
|
var cssmin = {};
|
2014-02-12 13:34:50 +00:00
|
|
|
|
2013-11-04 21:11:45 +00:00
|
|
|
_.each(files, function(val, key){
|
2014-02-12 13:34:50 +00:00
|
|
|
|
2013-11-04 21:11:45 +00:00
|
|
|
var js = uglify['build/' + key + '.js'] = [];
|
2014-02-12 13:34:50 +00:00
|
|
|
|
2013-11-04 21:11:45 +00:00
|
|
|
_.each(files[key]['js'], function(val){
|
|
|
|
|
js.push('public/' + val);
|
|
|
|
|
});
|
2014-02-12 13:34:50 +00:00
|
|
|
|
|
|
|
|
var css = cssmin['build/' + key + '.css'] = [];
|
|
|
|
|
|
2013-11-04 21:11:45 +00:00
|
|
|
_.each(files[key]['css'], function(val){
|
2014-02-12 13:34:50 +00:00
|
|
|
var path = (val == 'app.css' || val == 'static.css') ? 'build/' : 'public/';
|
|
|
|
|
css.push(path + val)
|
2013-11-04 21:11:45 +00:00
|
|
|
});
|
2014-02-12 13:34:50 +00:00
|
|
|
|
2013-11-04 21:11:45 +00:00
|
|
|
});
|
2015-02-05 17:20:40 +00:00
|
|
|
console.log(uglify);
|
|
|
|
|
console.log(cssmin);
|
2014-02-12 13:34:50 +00:00
|
|
|
|
2013-11-04 21:11:45 +00:00
|
|
|
grunt.config.set('uglify.build.files', uglify);
|
2014-02-12 13:34:50 +00:00
|
|
|
grunt.config.set('uglify.build.options', {compress: false});
|
|
|
|
|
|
2013-11-04 21:11:45 +00:00
|
|
|
grunt.config.set('cssmin.build.files', cssmin);
|
2014-02-12 13:34:50 +00:00
|
|
|
// Rewrite urls to relative path
|
|
|
|
|
grunt.config.set('cssmin.build.options', {'target': 'public/css/whatever-css.css'});
|
2013-11-04 21:11:45 +00:00
|
|
|
});
|
|
|
|
|
|
2013-09-06 17:19:43 +00:00
|
|
|
// Register tasks.
|
2013-11-04 21:11:45 +00:00
|
|
|
grunt.registerTask('build:prod', ['loadManifestFiles', 'clean:build', 'uglify', 'stylus', 'cssmin', 'copy:build', 'hashres']);
|
2014-02-12 12:59:13 +00:00
|
|
|
grunt.registerTask('build:dev', ['stylus']);
|
2015-02-05 17:20:40 +00:00
|
|
|
grunt.registerTask('test', ['loadManifestFiles', 'uglify', 'cssmin']);
|
2013-09-07 10:47:44 +00:00
|
|
|
|
|
|
|
|
grunt.registerTask('run:dev', [ 'build:dev', 'concurrent' ]);
|
2013-09-06 17:19:43 +00:00
|
|
|
|
|
|
|
|
// Load tasks
|
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-uglify');
|
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-clean');
|
2013-09-06 19:39:18 +00:00
|
|
|
grunt.loadNpmTasks('grunt-contrib-stylus');
|
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-cssmin');
|
2013-09-10 12:40:00 +00:00
|
|
|
grunt.loadNpmTasks('grunt-contrib-copy');
|
2013-09-07 10:47:44 +00:00
|
|
|
grunt.loadNpmTasks('grunt-nodemon');
|
|
|
|
|
grunt.loadNpmTasks('grunt-concurrent');
|
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-watch');
|
2013-09-10 10:39:17 +00:00
|
|
|
grunt.loadNpmTasks('grunt-hashres');
|
2013-09-14 01:19:02 +00:00
|
|
|
grunt.loadNpmTasks('grunt-karma');
|
2014-01-16 08:10:00 +00:00
|
|
|
grunt.loadNpmTasks('git-changelog');
|
2013-09-06 17:19:43 +00:00
|
|
|
|
|
|
|
|
};
|