-
Notifications
You must be signed in to change notification settings - Fork 2
/
gruntfile.js
156 lines (137 loc) · 3.46 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
/*global module:false*/
module.exports = function(grunt) {
var settings = grunt.file.readYAML('config.yml');
// load all grunt tasks matching the `grunt-*` pattern
require('load-grunt-tasks')(grunt);
// Project configuration.
grunt.initConfig({
// Project metadata.
pkg: grunt.file.readJSON('package.json'),
jshint: {
options: {
curly: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
asi: true,
sub: true,
undef: true,
// unused: true,
boss: true,
eqnull: true,
browser: true,
globals: {
Avgrund: true,
Mousetrap: true,
console: true,
Raphael: true,
require: true,
fs: true
}
},
gruntfile: {
src: 'gruntfile.js'
},
js: {
src: ['js/*.js','!js/plugins.js']
}
},
copy: {
dist: {
files: [
{
expand: true,
src: ['index.html','README.md','libraries/**/*'],
dest: 'dist/'
}
]
},
distSrc: {
files: [
{
expand: true,
src: ['index.html','README.md','libraries/**/*','js/**/*','css/**/*'],
dest: 'dist/src/'
}
]
}
},
useminPrepare: {
html: 'index.html',
options: {
dest: 'dist'
}
},
usemin: {
html: 'dist/index.html'
},
connect: {
server: {
options: {
port: settings.serverPort,
base: '.',
hostname: 'localhost',
livereload: true
// middleware: function(connect, options, middlewares) {
// // inject a custom middleware into the array of default middlewares
// middlewares.push(function(req, res, next) {
// if (req.url !== '/node_modules/pclock_savesvg') {
// return next();
// }
// res.end('Hello, world from port');
// });
// return middlewares;
// }
}
}
},
watch: {
options: {
livereload: settings.liveReloadPort
},
gruntfile: {
files: '<%= jshint.gruntfile.src %>',
tasks: ['jshint:gruntfile']
},
html: {
files: '*.html',
tasks: [ 'useminPrepare', 'copy:dist', 'usemin', 'copy:distSrc' ]
},
scripts: {
files: './js/*.js',
tasks: [ 'jshint:js' , 'copy:dist', 'useminPrepare', 'concat:generated', 'uglify:generated', 'copy:distSrc' ]
},
css: {
files: './css/**/*.css',
tasks: [ 'useminPrepare', 'cssmin:generated', 'copy:dist', 'copy:distSrc' ]
}
},
parallel: {
watch: {
options: {
grunt: true,
stream: true
},
tasks: ['watch']
}
}
});
// Default task eg. what happens when we simply run 'grunt'
grunt.registerTask(
'default',
'Runs linting on Javascript, concats and uflifys the js',
[ 'serve' ]
);
//////////////////////////////
// Server Task
//
grunt.registerTask('serve', 'start the dev server', function(){
// do a first run build
grunt.task.run(['useminPrepare','concat:generated','uglify:generated','cssmin:generated','copy:dist','usemin','copy:distSrc']);
// run the server task
grunt.task.run('connect');
// watch for changes
grunt.task.run('parallel:watch');
});
};