Added compilation tasks to Gruntfile.js

Added tasks to flatten the folder structure and rename the files and requires() accordingly.
Also added a task to insert a version.js with a global version variable as well as time-grunt to show the time it takes.
main
Peery 2 years ago
parent b31b4b9a67
commit 25960f100b

@ -1,4 +1,6 @@
module.exports = function(grunt) {
require('time-grunt')(grunt);
var config = require('./.credentials.json');
var branch = grunt.option('branch') || config.branch;
var email = grunt.option('email') || config.email;
@ -7,6 +9,14 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-screeps');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-file-append');
var current_date = new Date();
grunt.log.subhead('Task start: ' + current_date.toLocaleString())
grunt.log.writeln('Branch: ' + branch)
grunt.initConfig({
screeps: {
@ -19,6 +29,38 @@ module.exports = function(grunt) {
dist: {
src: ['dist/*.js']
}
},
clean: {
'dist': ['dist']
},
copy: { // Copy all source files into the dist folder, flattening the folder structure
screeps: {
files: [{
expand: true,
cwd: 'src/',
src: '**',
dest: 'dist/',
filter: 'isFile',
rename: function (dest, src) {
return dest + src.replace(/\//g, '_');
}
});
}],
}
},
file_append: {
versioning: {
files: [
{
append: "\nglobal.SCRIPT_VERSION = " + current_date.getTime() + "\n",
input: 'dist/version.js'
}
]
}
},
})
grunt.registerTask('default', ['clean', 'copy:screeps', 'file_append:versioning', 'screeps']);
}

Loading…
Cancel
Save