-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgruntfile.js
136 lines (123 loc) · 4.32 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
/**
* Created by halfthin on 2015/10/27.
*/
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: {
files: ['app.js', 'routes/*.js', '*.js'],
options: {
globals: {exports: true}
}
},
watch: {
less: {
files: ['public/stylesheets/*.less'],
tasks: ['less:dev'],
options: {nospawn: true}
},
server: {
files: ['.rebooted'],
options: {
livereload: true
}
}
},
less: {
dev: {
files: [{
expand: true,
cwd: 'public/stylesheets',
src: ['*.less'],
dest: 'public/stylesheets',
ext: '.css'
}],
options: {
paths: ['public/assets/css'],
compress: false,
yuicompress: false,
strictMath: true,
strictUnits: true,
strictImports: true
}
},
prod: {
options: {
files: {'public/stylesheets/style.css': 'public/stylesheets/style.less'},
paths: ['assets/css'],
plugins: [
new require('less-plugin-autoprefix')({browsers: ['last 2 versions']}),
new require('less-plugin-clean-css')()
],
modifyVars: {
imgPath: '',
bgColor: ''
}
}
}
},
concurrent: {
dev: ['jshint', 'less:dev', 'nodemon:dev', 'watch'],
prod: ['jshint', 'less:prod', 'nodemon:prod', 'watch'],
options: {
logConcurrentOutput: true
}
},
nodemon: {
dev: {
script: 'bin/www',
options: {
nodeArgs: [],
env: {
PORT: 3310
},
callback: function (nodemon) {
nodemon.on('log', function (event) {
console.log(event.colour);
});
}
}
},
prod: {
script: 'bin/www',
options: {
nodeArgs: [],
env: {
PORT: 80
},
// omit this property if you aren't serving HTML files and
// don't want to open a browser tab on start
callback: function (nodemon) {
nodemon.on('log', function (event) {
console.log(event.colour);
});
// opens browser on initial server start
nodemon.on('config:update', function () {
// Delay before server listens on port
setTimeout(function () {
//require('open')('http://localhost:5455');
}, 1000);
});
// refreshes browser when server reboots
nodemon.on('restart', function () {
// Delay before server listens on port
setTimeout(function () {
require('fs').writeFileSync('.rebooted', 'rebooted');
}, 1000);
});
}
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-nodemon');
grunt.loadNpmTasks('grunt-concurrent');
grunt.registerTask('default', ['concurrent:dev']);
grunt.registerTask('prod', ['concurrent:prod']);
};