mirror of
https://github.com/Doodle3D/doodle3d-client.git
synced 2024-11-21 17:07:55 +01:00
4a3da30ebd
The information is dynamically inserted when grunt is run.
182 lines
4.9 KiB
JavaScript
182 lines
4.9 KiB
JavaScript
/*global module:false*/
|
|
module.exports = function(grunt) {
|
|
|
|
// Project configuration.
|
|
grunt.initConfig({
|
|
// Metadata.
|
|
pkg: grunt.file.readJSON('package.json'),
|
|
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
|
|
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
|
|
'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
|
|
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
|
|
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
|
|
gitinfo: {
|
|
options: {},
|
|
commands: { 'tag': ['tag', '--points-at', 'HEAD'] }
|
|
},
|
|
template: {
|
|
'add_build_info': {
|
|
options: {
|
|
data: function() {
|
|
grunt.task.requires('gitinfo');
|
|
var gi = grunt.config('gitinfo');
|
|
var lbc = gi.local.branch.current;
|
|
|
|
var tag = (gi.tag == '') ? 'no_tag' : gi.tag;
|
|
var commitMsg = lbc.lastCommitMessage.slice(1, -1).split('\n')[0].replace(/"/g, '\\\"');
|
|
|
|
var buildInfo = lbc.shortSHA + "/" + lbc.name + "/" + tag +
|
|
" (" + lbc.lastCommitTime.slice(1, -1) + "; \'" + commitMsg + "'";
|
|
return { 'build_info': buildInfo };
|
|
}
|
|
},
|
|
files: {
|
|
'js/main.js.out': ['js/main.js']
|
|
}
|
|
}
|
|
},
|
|
concat: {
|
|
options: {
|
|
// separator: ';'
|
|
},
|
|
js: {
|
|
src: [
|
|
'js/api/*.js',
|
|
'js/settings/FormPanel.js',
|
|
'js/settings/*.js',
|
|
'js/*.js',
|
|
// make sure we put main.js last
|
|
'!js/main.js',
|
|
'js/main.js.out'
|
|
],
|
|
dest: 'www/js/<%= pkg.name %>.js'
|
|
}
|
|
},
|
|
uglify: {
|
|
options: {
|
|
// banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n',
|
|
mangle: true,
|
|
beautify: false,
|
|
compress: {},
|
|
// report: 'min',
|
|
preserveComments: 'some'
|
|
},
|
|
js: {
|
|
files: {
|
|
'www/js/<%= pkg.name %>.min.js' : ['www/js/<%= pkg.name %>.js']
|
|
}
|
|
},
|
|
jslibs: {
|
|
cwd: "js/libs/",
|
|
// src: ['js/libs/*.js', '!js/libs/*.min.js'], // source files mask
|
|
src: ['*.js', '!*.min.js'], // source files mask
|
|
dest: 'www/js/libs/', // destination folder
|
|
expand: true, // allow dynamic building
|
|
flatten: true, // remove all unnecessary nesting
|
|
ext: '.min.js' // replace .js to .min.js
|
|
// files: {
|
|
// 'www/js/<%= pkg.name %>.min.js' : ['www/js/<%= pkg.name %>.js']
|
|
// }
|
|
}
|
|
},
|
|
jshint: {
|
|
options: {
|
|
globals: {
|
|
jQuery: true
|
|
},
|
|
browser: true,
|
|
curly: true,
|
|
eqeqeq: true,
|
|
immed: true,
|
|
latedef: true,
|
|
newcap: true,
|
|
noarg: true,
|
|
sub: true,
|
|
undef: true,
|
|
unused: true,
|
|
boss: true,
|
|
eqnull: true
|
|
},
|
|
// gruntfile: {
|
|
// src: 'Gruntfile.js'
|
|
// },
|
|
lib_test: {
|
|
src: ['www/js/*.js', '!www/js/<%= pkg.name %>.js', '!www/js/<%= pkg.name %>.min.js']
|
|
}
|
|
},
|
|
less: {
|
|
development: {
|
|
options: {
|
|
paths: ["www/css"]
|
|
},
|
|
files: {
|
|
"www/css/styles.css": "less/styles.less"
|
|
}
|
|
}
|
|
},
|
|
watch: {
|
|
javascript: {
|
|
files: ["js/**", '!www/js/<%= pkg.name %>.min.js', '!www/js/<%= pkg.name %>.js'],
|
|
tasks: ["concat:js", "uglify:js"]
|
|
// tasks: ["jshint", "concat", "uglify"]
|
|
},
|
|
javascriptLibs: {
|
|
files: ["js/libs/*"],
|
|
tasks: ["uglify:jslibs"]
|
|
// tasks: ["jshint", "concat", "uglify"]
|
|
},
|
|
styles: {
|
|
files: ["less/*"],
|
|
tasks: ["less", "autoprefixer", "cssmin"]
|
|
}
|
|
},
|
|
autoprefixer: {
|
|
options: {
|
|
browsers: ['> 1%', 'last 2 versions', 'ie 8', 'ie 9', 'ff 17', 'opera 12.1']
|
|
},
|
|
// prefix all specified files and save them separately
|
|
single_file: {
|
|
options: {},
|
|
// expand: true,
|
|
// flatten: true,
|
|
src: 'www/css/styles.css', // -> src/css/file1.css, src/css/file2.css
|
|
dest: 'www/css/styles.css' // -> dest/css/file1.css, dest/css/file2.css
|
|
}
|
|
},
|
|
cssmin: {
|
|
minify: {
|
|
expand: true,
|
|
cwd: 'www/css/',
|
|
src: ['*.css', '!*.min.css'],
|
|
dest: 'www/css/',
|
|
ext: '.min.css'
|
|
}
|
|
}
|
|
});
|
|
|
|
// These plugins provide necessary tasks.
|
|
grunt.loadNpmTasks('grunt-gitinfo');
|
|
grunt.loadNpmTasks('grunt-template');
|
|
grunt.loadNpmTasks('grunt-contrib-less');
|
|
grunt.loadNpmTasks('grunt-contrib-concat');
|
|
grunt.loadNpmTasks('grunt-contrib-uglify');
|
|
grunt.loadNpmTasks('grunt-contrib-jshint');
|
|
grunt.loadNpmTasks('grunt-contrib-watch');
|
|
grunt.loadNpmTasks('grunt-autoprefixer');
|
|
grunt.loadNpmTasks('grunt-contrib-cssmin');
|
|
|
|
// Default task.
|
|
grunt.registerTask('default', [
|
|
'gitinfo',
|
|
'template',
|
|
'less',
|
|
'autoprefixer',
|
|
'cssmin',
|
|
'concat',
|
|
'uglify',
|
|
// 'jshint',
|
|
'watch'
|
|
]);
|
|
|
|
};
|