-
Notifications
You must be signed in to change notification settings - Fork 3
/
Gruntfile.js
94 lines (84 loc) · 2.21 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
"use strict";
module.exports = function(grunt) {
require("matchdep").filterDev("grunt-*").forEach(grunt.loadNpmTasks);
grunt.initConfig({
// Define Directory
dirs: {
js: "src",
build: "dist"
},
// Metadata
pkg: grunt.file.readJSON("package.json"),
banner:
"/*!\n" +
" * -------------------------------------------------------\n" +
" * Project: <%= pkg.title %>\n" +
" * Version: <%= pkg.version %>\n" +
" *\n" +
" * Author: <%= pkg.author.name %>\n" +
" * Site: <%= pkg.author.url %>\n" +
" * Contact: <%= pkg.author.email %>\n" +
" *\n" +
" * Copyright (c) <%= grunt.template.today(\"yyyy\") %> <%= pkg.author.name %>\n" +
" * License: <%= pkg.licenses[0].url %>\n"+
" *\n" +
" * Stars data credits: https://edu.kde.org/kstars, http://www.astronexus.com/hyg\n" +
" * -------------------------------------------------------\n" +
" */\n" +
"\n",
// Minify and Concat archives
uglify: {
options: {
banner: "<%= banner %>",
mangle: true,
sequences: true,
dead_code: true,
conditionals: true,
booleans: true,
unused: true,
if_return: true,
join_vars: true
},
dist: {
files: {
"<%= dirs.build %>/<%= pkg.name %>.min.js": "<%= dirs.build %>/<%= pkg.name %>.js"
}
}
},
// Notifications
notify: {
js: {
options: {
title: "Javascript - <%= pkg.title %>",
message: "Minified and validated with success!"
}
}
},
requirejs: {
compile: {
options: {
findNestedDependencies: true,
baseUrl: "<%= dirs.js %>",
mainConfigFile: "<%= dirs.js %>/main.js",
name: "SkySphere",
optimize: 'none',
transformAMDChecks: false,
out: "<%= dirs.build %>/<%= pkg.name %>.js",
onModuleBundleComplete: function(data) {
var fs = require('fs'), amdclean = require('amdclean'), outputFile = data.path;
fs.writeFileSync(outputFile, amdclean.clean({
filePath: outputFile,
prefixMode: 'camelCase',
wrap: {
start: grunt.file.read("src/intro.js"),
end: "\nreturn SkySphere;\n}));"
}
}));
}
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.registerTask( "default", [ "requirejs", "uglify" ]);
};