This repository has been archived by the owner on May 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGruntfile.js
168 lines (157 loc) · 4.37 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
module.exports = function(grunt) {
var ends_with = function (str1, str2) {
return str1.slice(str1.length-str2.length) == str2;
};
var inc_libs = require('./include_libs');
var runtime_and_editor = inc_libs.runtime.concat(inc_libs.editor);
var src_js = runtime_and_editor.filter(function(f) { return ends_with(f, ".js");});
var build_folder = ".build";
var exclude_regexes = [
"jquery-.*\\.js",
"raphael\\.js",
"underscore\\.js",
"underscore\\.deferred\\.js",
"esprima\\.js",
"ace\\.js"
];
var my_src_files = src_js.filter(function(f) {
for(var i = 0; i<exclude_regexes.length; i++) {
var exclude_regex = new RegExp(exclude_regexes[i]);
if(f.match(exclude_regex)) {
return false;
}
}
return true;
});
var package = grunt.file.readJSON('package.json');
// Project configuration
grunt.initConfig({
pkg: package,
jshint: {
build: {
src: my_src_files
}
},
uglify: {
build: {
options: {
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd h:MM:ss TT") %> */',
global_defs: {
DEBUG: false
},
sourceMapIn: ".build/interstate.js.map",
sourceMap: ".build/interstate.min.js.map",
sourceMappingURL: "interstate.min.js.map"
},
src: build_folder + "/interstate.js",
dest: build_folder + "/interstate.min.js"
}
},
concat: {
esprima: {
src: "src/_vendor/esprima/esprima.js",
dest: build_folder + "/vendor/esprima.js"
},
qrcode: {
src: "src/_vendor/qrcode.min.js",
dest: build_folder + "/vendor/qrcode.min.js"
}
},
concat_sourcemap: {
js: {
options: {
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd h:MM:ss TT") %> */',
process: {
data: {
version: package.version,
build_time: grunt.template.today("yyyy-mm-dd h:MM:ss TT")
}
},
sourceRoot: '..'
},
src: src_js,
dest: build_folder + "/interstate.js"
}
},
sass: {
editor_style: {
files: [{
dest: build_folder + "/editor/style/editor_style.css",
src: "src/view/editor/style/editor_style.scss"
}]
}, runtime_style: {
files: [{
dest: build_folder + "/editor/style/runtime_style.css",
src: "src/view/editor/style/runtime_style.scss"
}]
}
},
copy: {
css: {
files: [
{ expand: true, cwd: "src/view/editor/style/images", src: ["**"], dest: build_folder + "/editor/style/images" },
{ expand: true, cwd: "src/view/editor/style/fonts", src: ["**"], dest: build_folder + "/editor/style/fonts" }
]
},
sample_apps: {
files: [
{ expand: true, cwd: "sample_apps/", src: ["**"], dest: build_folder + "/sample_apps" }
]
},
carousel_images: {
files: [
{ expand: true, cwd: "carousel_images/", src: ["**"], dest: build_folder + "/carousel_images" }
]
},
ace: {
files: [
{ expand: true, cwd: "src/_vendor/ace", src: ["**"], dest: build_folder + "/vendor/ace" },
]
},
box2d: {
files: [
{ expand: true, cwd: "src/_vendor/Box2dWeb-2.1a.3", src: ["**"], dest: build_folder + "/vendor/Box2dWeb-2.1a.3" },
]
},
dist: {
files: [
{ expand: true, cwd: "dist/", src: ["**"], dest: build_folder + "/" }
]
}
},
clean: {
build: ["build/"]
},
qunit: {
all: {
options: {
urls: ['http://localhost:8000/test/unit_tests/unit_tests.ejs.html']
}
}
},
watch: {
dev: {
files: my_src_files.concat(['test/unit_tests/*.js']),
tasks: ['jshint', 'qunit']
}
}
});
// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-concat-sourcemap');
// Default task(s).
grunt.registerTask('full', ['jshint', 'concat', 'concat_sourcemap', 'uglify', 'sass', 'copy']);
grunt.registerTask('default', ['concat', 'concat_sourcemap', 'uglify', 'sass', 'copy']);
grunt.registerTask('quick', ['jshint', 'concat', 'concat_sourcemap', 'sass', 'copy']);
grunt.registerTask('test', ['jshint', 'qunit']);
grunt.registerTask('dev', ['jshint', 'qunit', 'watch']);
};