forked from filamentgroup/shoestring
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
149 lines (123 loc) · 3.2 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
/* global module:false */
module.exports = function(grunt) {
var fs, files, opts, spawn, builds = {};
opts = {
baseUrl: "src",
name: "../build/REPLACE",
out: "dist/REPLACE.js",
mainConfigFile: "build/config/production.js"
};
fs = require( 'fs' );
files = fs.readdirSync( "build/custom/" );
files.forEach(function( file ) {
if( /\.js$/.test(file) ){
var name = file.replace(/\.js$/, ""),
o = Object.create(opts);
builds[name] = {
options: o
};
builds[name].options.name = o.name.replace("REPLACE", "custom/" + name );
builds[name].options.out = o.out.replace("REPLACE", name );
}
});
builds.production = {
options: {
baseUrl: "src",
name: "../build/production",
out: "dist/production.js",
mainConfigFile: "build/config/production.js"
}
};
// NOTE config includes development
builds.development = {
options: {
baseUrl: "src",
// NOTE uses the same meta-module as production
name: "../build/development",
out: "dist/development.js",
mainConfigFile: "build/config/development.js"
}
};
// Project configuration.
grunt.initConfig({
meta: {
version: '1.0.3',
banner: '/*! Shoestring - v<%= meta.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'* http://github.com/filamentgroup/shoestring/\n' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> ' +
'Scott Jehl, Filament Group, Inc; Licensed MIT & GPLv2 */ \n'
},
qunit: {
files: ['test/unit/*.html']
},
requirejs: builds,
// NOTE purely for the banner
concat: {
options: {
banner: '<%= meta.banner %>',
stripBanners: true
},
production: {
src: ['dist/production.js'],
dest: 'dist/shoestring.js'
},
development: {
src: ['dist/development.js'],
dest: 'dist/shoestring-dev.js'
}
},
uglify: {
all: {
options: {
banner: '<%= meta.banner %>',
report: 'gzip'
},
files: {
'dist/shoestring.min.js': ['dist/shoestring.js'],
'dist/shoestring-dev.min.js': ['dist/shoestring-dev.js']
}
}
},
jshint: {
all: {
options: {
jshintrc: ".jshintrc",
},
src: ['Gruntfile.js', 'src/**/*.js']
}
},
watch: {
js: {
files: [
'src/**'
],
tasks: 'default'
}
}
});
spawn = require('child_process').spawn;
grunt.registerTask('docs', function() {
var doxx, srcs, args = [], done = this.async();
for(var i in arguments){
args.push(arguments[i]);
}
srcs = args.length ? srcs = args.join(":") : "src";
doxx = spawn( 'node', ['node_modules/.bin/doxx', '--source', srcs, '--target', 'dist/docs']);
doxx.on( 'close', function( code ) {
console.log( "doxx completed with exit code: " + code );
done();
});
});
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-contrib-watch');
// Default task.
grunt.registerTask('build', 'requirejs concat uglify'.split(' ') );
grunt.registerTask('test', 'jshint qunit'.split(' ') );
grunt.registerTask('default', 'build test'.split(' ') );
};