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
|
module.exports = function(grunt) {
// 1. All configuration goes here
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
express: {
options: {
// Override the command used to start the server.
// (do not use 'coffee' here, the server will not be able to restart
// see below at opts for coffee-script support)
cmd: process.argv[0],
// Will turn into: `node OPT1 OPT2 ... OPTN path/to/server.js ARG1 ARG2 ... ARGN`
// (e.g. opts: ['node_modules/coffee-script/bin/coffee'] will correctly parse coffee-script)
opts: [ ],
args: [ ],
// Setting to `false` will effectively just run `node path/to/server.js`
background: true,
// Called when the spawned server throws errors
fallback: function() {},
// Override node env's PORT
// port: 3000,
// Override node env's NODE_ENV
// node_env: undefined,
// Consider the server to be "running" after an explicit delay (in milliseconds)
// (e.g. when server has no initial output)
delay: 0,
// Regular expression that matches server output to indicate it is "running"
output: ".+",
// Set --debug (true | false | integer from 1024 to 65535, has precedence over breakOnFirstLine)
debug: false,
// Set --debug-brk (true | false | integer from 1024 to 65535)
breakOnFirstLine: false,
// Object with properties `out` and `err` both will take a path to a log file and
// append the output of the server. Make sure the folders exist.
logs: undefined
},
dev: {
options: {
script: 'bin/app.js'
}
},
// prod: {
// options: {
// script: 'path/to/prod/server.js',
// node_env: 'production'
// }
// },
// test: {
// options: {
// script: 'path/to/test/server.js'
// }
// }
},
watch: {
options: {
livereload: true
},
webserver: {
files: [ 'bin/app.js', 'config/*' ],
tasks: [ 'express:dev' ],
options: {
spawn: false
}
},
// less: {
// files: ["public/**/*.less"],
// tasks: ["less"],
// options: {
// livereload: false
// }
// },
public: {
files: ["public/**/*.css", "public/**/*.js"]
}
}
});
// 3. Where we tell Grunt we plan to use this plug-in.
grunt.loadNpmTasks('grunt-express-server');
grunt.loadNpmTasks('grunt-contrib-watch');
// 4. Where we tell Grunt what to do when we type "grunt" into the terminal.
grunt.registerTask('default', ['express','watch']);
};
|