mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-05-20 12:48:52 +00:00
Restored Grunt tasks
This commit is contained in:
parent
71a2382b67
commit
157a635a0c
1 changed files with 130 additions and 5 deletions
135
Gruntfile.js
135
Gruntfile.js
|
|
@ -25,6 +25,58 @@ module.exports = function(grunt) {
|
|||
}
|
||||
},
|
||||
|
||||
karma: {
|
||||
unit: {
|
||||
configFile: 'karma.conf.js'
|
||||
},
|
||||
continuous: {
|
||||
configFile: 'karma.conf.js',
|
||||
singleRun: true,
|
||||
autoWatch: false
|
||||
}
|
||||
},
|
||||
|
||||
clean: {
|
||||
build: ['website/build']
|
||||
},
|
||||
|
||||
stylus: {
|
||||
build: {
|
||||
options: {
|
||||
compress: false, // AFTER
|
||||
'include css': true,
|
||||
paths: ['website/public']
|
||||
},
|
||||
files: {
|
||||
'website/build/app.css': ['website/public/css/index.styl'],
|
||||
'website/build/static.css': ['website/public/css/static.styl']
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
browserify: {
|
||||
dist: {
|
||||
src: ["common/script/index.js"],
|
||||
dest: "common/dist/scripts/habitrpg-shared.js"
|
||||
},
|
||||
options: {
|
||||
transform: ['coffeeify']
|
||||
//debug: true Huge data uri source map (400kb!)
|
||||
}
|
||||
},
|
||||
|
||||
copy: {
|
||||
build: {
|
||||
files: [
|
||||
{expand: true, cwd: 'website/public/', src: 'favicon.ico', dest: 'website/build/'},
|
||||
{expand: true, cwd: '', src: 'common/dist/sprites/spritesmith*.png', dest: 'website/build/'},
|
||||
{expand: true, cwd: '', src: 'common/img/sprites/backer-only/*.gif', dest: 'website/build/'},
|
||||
{expand: true, cwd: '', src: 'common/img/sprites/npc_ian.gif', dest: 'website/build/'},
|
||||
{expand: true, cwd: 'website/public/', src: 'bower_components/bootstrap/dist/fonts/*', dest: 'website/build/'}
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
// UPDATE IT WHEN YOU ADD SOME FILES NOT ALREADY MATCHED!
|
||||
hashres: {
|
||||
build: {
|
||||
|
|
@ -32,19 +84,92 @@ module.exports = function(grunt) {
|
|||
fileNameFormat: '${name}-${hash}.${ext}'
|
||||
},
|
||||
src: [
|
||||
'website/build/*.js', 'website/build/*.css', 'website/build/favicon.ico',
|
||||
'website/build/common/dist/sprites/*.png',
|
||||
'website/build/common/img/sprites/backer-only/*.gif',
|
||||
'website/build/common/img/sprites/npc_ian.gif',
|
||||
'website/build/*.js',
|
||||
'website/build/*.css',
|
||||
'website/build/favicon.ico',
|
||||
'website/build/bower_components/habitrpg-shared/dist/*.png',
|
||||
'website/build/bower_components/habitrpg-shared/img/sprites/backer-only/*.gif',
|
||||
'website/build/bower_components/habitrpg-shared/img/sprites/npc_ian.gif',
|
||||
'website/build/bower_components/bootstrap/dist/fonts/*'
|
||||
],
|
||||
dest: 'build/*.css'
|
||||
dest: 'website/build/*.css'
|
||||
}
|
||||
},
|
||||
|
||||
nodemon: {
|
||||
dev: {
|
||||
script: '<%= pkg.main %>'
|
||||
}
|
||||
},
|
||||
|
||||
watch: {
|
||||
dev: {
|
||||
files: ['website/public/**/*.styl'], // 'public/**/*.js' Not needed because not in production
|
||||
tasks: [ 'build:dev' ],
|
||||
options: {
|
||||
nospawn: true
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
concurrent: {
|
||||
dev: ['nodemon', 'watch'],
|
||||
options: {
|
||||
logConcurrentOutput: true
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
//Load build files from public/manifest.json
|
||||
grunt.registerTask('loadManifestFiles', 'Load all build files from public/manifest.json', function(){
|
||||
var files = grunt.file.readJSON('./website/public/manifest.json');
|
||||
var uglify = {};
|
||||
var cssmin = {};
|
||||
|
||||
_.each(files, function(val, key){
|
||||
|
||||
var js = uglify['website/build/' + key + '.js'] = [];
|
||||
|
||||
_.each(files[key].js, function(val){
|
||||
js.push('website/public/' + val);
|
||||
});
|
||||
|
||||
var css = cssmin['website/build/' + key + '.css'] = [];
|
||||
|
||||
_.each(files[key].css, function(val){
|
||||
var path = (val == 'app.css' || val == 'static.css') ? 'website/build/' : 'website/public/';
|
||||
css.push(path + val)
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
grunt.config.set('uglify.build.files', uglify);
|
||||
grunt.config.set('uglify.build.options', {compress: false});
|
||||
|
||||
grunt.config.set('cssmin.build.files', cssmin);
|
||||
// Rewrite urls to relative path
|
||||
grunt.config.set('cssmin.build.options', {'target': 'website/public/css/whatever-css.css'});
|
||||
});
|
||||
|
||||
// Register tasks.
|
||||
grunt.registerTask('build:prod', ['loadManifestFiles', 'clean:build', 'browserify', 'uglify', 'stylus', 'cssmin', 'copy:build', 'hashres']);
|
||||
grunt.registerTask('build:dev', ['browserify', 'stylus']);
|
||||
|
||||
grunt.registerTask('run:dev', [ 'build:dev', 'concurrent' ]);
|
||||
|
||||
// Load tasks
|
||||
grunt.loadNpmTasks('grunt-browserify');
|
||||
grunt.loadNpmTasks('grunt-contrib-uglify');
|
||||
grunt.loadNpmTasks('grunt-contrib-clean');
|
||||
grunt.loadNpmTasks('grunt-contrib-stylus');
|
||||
grunt.loadNpmTasks('grunt-contrib-cssmin');
|
||||
grunt.loadNpmTasks('grunt-contrib-copy');
|
||||
grunt.loadNpmTasks('grunt-nodemon');
|
||||
grunt.loadNpmTasks('grunt-concurrent');
|
||||
grunt.loadNpmTasks('grunt-contrib-watch');
|
||||
grunt.loadNpmTasks('grunt-hashres');
|
||||
grunt.loadNpmTasks('grunt-karma');
|
||||
grunt.loadNpmTasks('git-changelog');
|
||||
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue