'min/moment.min.js' : ['moment.js']
};
+ var minLangs = {
+ langs: {
+ src: ['min/langs.js'],
+ dest: 'min/langs.min.js'
+ }
+ };
+
// all the lang files need to be added manually
fs.readdirSync('./lang').forEach(function (path) {
if (path.indexOf('.js') > -1) {
var dest = 'min/lang/' + path,
src = ['lang/' + path];
+
minifiedFiles[dest] = src;
+ minLangs[path] = {src:src, dest:dest};
}
});
dest: 'min/langs.js'
}
},
+ minlang : minLangs,
uglify : {
my_target: {
files: minifiedFiles
},
options: {
- mangle: true,
+ mangle: {
+ toplevel: true
+ },
squeeze: {
dead_code: false
},
module.exports = function (grunt) {
+ var helpers = require('grunt-lib-legacyhelpers').init(grunt);
+
var START = [
"(function(){",
" function onload (moment) {",
// UglifyJS does not support keeping the first line comments unless using the CLI.
// This multi-task ensures that the first comments are kept.
grunt.registerMultiTask('minlang', 'Minify lang files with UglifyJS.', function () {
- var files = grunt.file.expandFiles(this.file.src),
+ var files = grunt.file.expand(this.data.src),
min,
code,
comments,
// Concat specified files. This should really be a single, pre-built (and
// linted) file, but it supports any number of files.
- code = grunt.helper('concat', files, {separator: this.data.separator});
+ code = helpers.concat(files, {separator: this.data.separator});
// Add the first comments
tok = uglifyjs.parser.tokenizer(code);
min = showCopyright(tok().comments_before);
// Add the minified source.
- min += grunt.helper('uglify', wrapFile(code), grunt.config('uglify'));
- grunt.file.write(this.file.dest, min);
+ min += uglifyjs(wrapFile(code), grunt.config('uglify'));
+ grunt.file.write(this.data.dest, min);
// Fail task if errors were logged.
if (this.errorCount) { return false; }
// Otherwise, print a success message....
- grunt.log.writeln('File "' + this.file.dest + '" created.');
+ grunt.log.writeln('File "' + this.data.dest + '" created.');
// ...and report some size information.
- grunt.helper('min_max_info', min, code);
+ helpers.min_max_info(min, code);
});
// Helper for the 'mincomment' multitask