forked from npr/responsiveiframe
-
Notifications
You must be signed in to change notification settings - Fork 114
/
Gruntfile.js
183 lines (177 loc) · 4.82 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/*global module:false*/
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
// Load package config
pkg: grunt.file.readJSON('package.json'),
// Task configuration.
jshint: {
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
expr: true,
sub: true,
node: true,
undef: true,
unused: true,
boss: true,
eqnull: true,
globals: {
jQuery: true,
requirejs: true,
}
},
conf: [
"Gruntfile.js",
"bower.json",
"package.json",
],
pym: {
options: {
browser: true,
predef: ['define']
},
src: "src/**/*.js",
}
},
jsdoc: {
dist: {
src: ["src/**/*.js", "README.md", "package.json"],
dest: "api",
options: {
template : "node_modules/minami",
configure : "jsdoc.conf.json"
}
}
},
replace: {
loader: {
options: {
patterns: [{
match: 'defaultPymUrl',
replacement: '<%= pkg.defaultPymUrl %>'
}]
},
files: [
{expand: true, flatten: true, src: ['src/pym-loader.js'], dest: 'build/'}
]
}
},
preprocess: {
options: {
context : {
// Comment if we want autoinit to be stripped out
AUTOINIT: true,
ENV: 'production'
}
},
pym : {
src : 'src/pym.js',
dest : 'build/pym.js'
},
loader : {
src : 'build/pym-loader.js',
dest : 'build/pym-loader.js'
},
},
concat: {
pym: {
options: {
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
src: ['build/pym.js'],
dest: 'dist/pym.v<%= pkg.version[0] %>.js'
},
loader: {
options: {
banner: '/*! pym-loader.js - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
src: ['build/pym-loader.js'],
dest: 'dist/pym-loader.v<%= pkg.version[0] %>.js'
},
},
karma: {
local: {
configFile: 'karma.conf.js',
background: true,
singleRun: false
},
sauce: {
configFile: 'karma.conf-sauce.js',
background: true,
singleRun: false
}
},
uglify: {
pym: {
options: {
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
files: {
'dist/p.v<%= pkg.version[0] %>.m.js': ['dist/pym.v<%= pkg.version[0] %>.js'],
'dist/pym.v<%= pkg.version[0] %>.min.js': ['dist/pym.v<%= pkg.version[0] %>.js']
}
},
loader: {
options: {
banner: '/*! pym-loader.js - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
files: {
'dist/pl.v<%= pkg.version[0] %>.m.js': ['dist/pym-loader.v<%= pkg.version[0] %>.js'],
'dist/pym-loader.v<%= pkg.version[0] %>.min.js': ['dist/pym-loader.v<%= pkg.version[0] %>.js']
}
}
},
watch: {
local: {
files: ["src/**/*.js", "test/**/*.js", "test/**/*.html"],
tasks: ["karma:local:run"] //NOTE the :run flag
},
sauce: {
files: ["src/**/*.js", "test/**/*.js", "test/**/*.html"],
tasks: ["karma:sauce:run"] //NOTE the :run flag
},
server: {
files: ["src/**/*.js", "examples/**/*"],
options: {
livereload: true
}
}
},
// via http://rhumaric.com/2013/07/renewing-the-grunt-livereload-magic/
express: {
all: {
options: {
port: 9000,
hostname: "localhost",
bases: ['.'],
livereload: true,
open: 'http://localhost:<%= express.all.options.port%>/examples/simple/'
}
}
},
});
// These plugins provide necessary tasks.
grunt.loadNpmTasks("grunt-contrib-jshint");
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-jsdoc");
grunt.loadNpmTasks('grunt-replace');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-preprocess');
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-express');
// Default task.
grunt.registerTask("default", ["jshint", "replace", "preprocess", "concat", "uglify", "jsdoc"]);
grunt.registerTask("test", ["karma:local:start", "watch:local"]);
grunt.registerTask("sauce", ["karma:sauce:start", "watch:sauce"]);
grunt.registerTask("server", ["express", "watch:server"]);
};