/
Gruntfile.js
158 lines (139 loc) · 3.98 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
module.exports = function(grunt) {
// configure the tasks
grunt.initConfig({
// JS TASKS ================================================================
// check all js files for errors
jshint: {
options: {
jshintrc: '.jshintrc'
},
all: ['public/scripts/app.js', 'public/scripts/**/*.js', 'server/**/*.js'],
},
// take all the js files and minify them into app.min.js
uglify: {
build: {
options: {
// beautify: true,
mangle: false
},
files: {
'public/dist/app.min.js': ['public/scripts/**/*.js']
}
}
},
// build every .styl file to a single site.css file
stylus: {
options: {
compress: true
},
compile: {
files: {
'public/styles/site.css': ['public/styles/*.styl']
}
}
},
// minify site css and themes css
// and move them to the distribution folder
cssmin: {
add_banner: {
options: {
banner: '/* Minified site css file */'
},
files: {
'public/dist/styles/site.min.css': ['public/styles/*.css'],
}
},
minify: {
expand: true,
cwd: 'public/styles/themes',
src: ['*.css', '!*.min.css'],
dest: 'public/dist/styles/themes',
ext: '.min.css'
}
},
// compile directive templates
jade: {
compile: {
options: {
data: {}
},
files: [{
expand: true,
src: ['public/views/directive-templates/**/*.jade'],
ext: '.html'
}]
}
},
// watch css and js files and process the above tasks
watch: {
options: {
livereload: true,
},
jade: {
files: ['public/views/**/*.jade', 'server/views/**/*.jade'] // Watch the jade files and just reload page (without compilations)
},
jadeCompile: {
files: 'public/views/directive-templates/**/*.jade',
tasks: ['newer:jade']
},
stylus: {
files: ['public/styles/*.styl'],
tasks: ['newer:stylus']
},
css: {
files: ['public/styles/**/**.css'],
tasks: ['newer:cssmin']
},
js: {
files: ['server/**/*.js', 'public/scripts/app.js', 'public/scripts/**/*.js', ],
tasks: ['jshint', 'uglify']
}
},
// watch our node server for changes
nodemon: {
dev: {
script: 'server.js'
}
},
// run watch and nodemon at the same time
concurrent: {
options: {
logConcurrentOutput: true
},
tasks: ['nodemon', 'watch']
},
// open the app in the browser
open: {
server: {
url: 'http://localhost:3030'
}
},
});
// load the tasks
grunt.loadNpmTasks('grunt-nodemon');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-stylus');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-jade');
grunt.loadNpmTasks('grunt-open');
grunt.loadNpmTasks('grunt-concurrent');
grunt.loadNpmTasks('grunt-newer');
// define the tasks
// Default: check with jshint, build everything, run server and watch for changes
grunt.registerTask(
'default',
[ 'jshint', 'newer:stylus', 'newer:cssmin', 'newer:jade', 'uglify', 'open', 'concurrent' ]
);
// JShint: check all javascript files
grunt.registerTask(
'JShint',
[ 'jshint' ]
);
// Build: check javascript with jshint, and then make a new build of everything
grunt.registerTask(
'build',
[ 'jshint', 'stylus', 'newer:jade', 'cssmin', 'uglify' ]
);
};