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 16
/
Gruntfile.js
154 lines (149 loc) · 4.59 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
module.exports = function(grunt) {
var package = grunt.file.readJSON('package.json'), // Project configuration.
src_files = ["src/util.js", "src/core.js", "src/array.js", "src/map.js", "src/liven.js",
"src/memoize.js", "src/binding.js", "src/state_machine/cjs_fsm.js",
"src/state_machine/cjs_events.js", "src/template/cjs_parser.js",
"src/template/cjs_template.js", "src/template/jsep.js"],
enclosed_src_files = (["src/header.js"]).concat(src_files, "src/footer.js");
grunt.initConfig({
pkg: package,
jshint: {
source: {
src: src_files
},
post_concat: {
src: "build/cjs.js"
}
},
uglify: {
development: {
options: {
banner: '/* <%= pkg.name %> - v<%= pkg.version %> (<%= pkg.homepage %>) */',
report: 'gzip',
sourceMapIn: "build/cjs.js.map",
sourceMap: "build/cjs.min.js.map",
sourceMappingURL: "cjs.min.js.map",
sourceMapPrefix: 1
},
src: "build/cjs.js", // Use concatenated files
dest: "build/cjs.min.js"
},
production: {
options: {
banner: '/* <%= pkg.name %> - v<%= pkg.version %> (<%= pkg.homepage %>) */',
sourceMap: "build/cjs.min.js.map",
sourceMappingURL: "cjs.min.js.map",
sourceMapPrefix: 1
},
src: "build/cjs.js", // Use concatenated files
dest: "build/cjs.min.js"
}
},
concat_sourcemap: {
options: {
process: {
data: {
version: package.version // the updated version will be added to the concatenated file
}
},
sourceRoot: '..'
},
js: {
src: enclosed_src_files,
dest: "build/cjs.js"
}
},
concat: {
js: {
options: {
stripBanners: true,
process: {
data: {
version: package.version // the updated version will be added to the concatenated file
}
}
},
src: enclosed_src_files,
dest: "build/cjs.js"
}
},
qunit: {
files: ['test/unit_tests.html']
},
clean: {
build: ["build/"]
},
watch: {
test: {
files: src_files.concat(['test/unit_tests.js', 'test/unit_tests/*.js']),
tasks: ['jshint:source', 'concat_sourcemap', 'jshint:post_concat', 'qunit']
},
quickdev: {
files: src_files,
tasks: ['concat_sourcemap']
},
full: {
files: src_files.concat(['test/unit_tests.js', 'test/unit_tests/*.js']),
tasks: ['jshint:source', 'concat_sourcemap', 'jshint:post_concat', 'qunit', 'uglify']
},
docs: {
files: enclosed_src_files.concat(['resources/api_doc_generator/views/*', 'resources/api_doc_generator/lib/**']),
tasks: ['dox']
}
},
compress: {
production: {
options: {
archive: '<%= pkg.name %>-<%= pkg.version %>.zip'
},
files: [{
expand: true,
cwd: 'build/',
src: '*',
dest: '<%= pkg.name %>-<%= pkg.version %>'
}]
}
},
dox: {
options: {
title: "ConstraintJS Documentation",
blob_name: "v<%= pkg.version %>"
},
files: {
src: enclosed_src_files,
dest: 'api'
}
}
});
grunt.registerTask('usetheforce_on', 'force the force option on if needed',
function() {
if (!grunt.option('force')) {
grunt.config.set('usetheforce_set', true);
grunt.option( 'force', true );
}
});
grunt.registerTask('usetheforce_restore', 'turn force option off if we have previously set it',
function() {
if (grunt.config.get('usetheforce_set')) {
grunt.option( 'force', false );
}
});
// 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-clean');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-concat-sourcemap');
grunt.loadTasks('./resources/api_doc_generator/tasks');
// Default task(s).
grunt.registerTask('default', ['clean', 'jshint:source', 'concat', 'jshint:post_concat', 'qunit', 'uglify:production', 'dox']);
grunt.registerTask('dev', ['clean', 'jshint:source', 'concat_sourcemap', 'jshint:post_concat', 'qunit', 'uglify:development']);
grunt.registerTask('package', ['clean', 'jshint:source', 'concat', 'jshint:post_concat', 'qunit', 'uglify:production', 'compress', 'dox']);
grunt.registerTask('docs', ['dox']);
grunt.registerTask('watch_dev', ['usetheforce_on', 'concat_sourcemap', 'watch:quickdev', 'usetheforce_restore']);
grunt.registerTask('watch_doc', ['dox', 'watch:docs']);
grunt.registerTask('watch_dev_full', ['usetheforce_on', 'jshint:source', 'concat_sourcemap', 'jshint:post_concat', 'qunit', 'uglify:development', 'watch:full', 'usetheforce_restore']);
};