-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
executable file
·86 lines (81 loc) · 1.8 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
module.exports = function (grunt) {
'use strict';
var port = grunt.option('port') || 9001,
lrPort = grunt.option('lr-port') || 35729,
hostname = 'localhost',
baseFolder = '.';
// Display the elapsed execution time of grunt tasks
require('time-grunt')(grunt);
// Lazy load all Grunt tasks
require('jit-grunt')(grunt);
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// Find available port in range
portPick: {
options: {
limit: 20
},
localServer: {
options: {
port: port
},
targets: ['connect.server.options.port']
},
LiveReload: {
options: {
port: lrPort,
// Needed since Watch is being reset every time
name: 'port-pick-livereload'
},
targets: [
'watch.options.livereload',
'connect.server.options.livereload'
]
}
},
// Trigger relevant tasks when the files they watch has been changed
// This includes adding/deleting files/folders as well
watch: {
// Will try to connect to a LiveReload script
options: {
livereload: '<%= grunt.config.get("port-pick-livereload") %>'
},
configs: {
options: {
reload: true
},
files: ['Gruntfile.js', 'package.json']
},
app: {
files: [
'app/**/*',
'css/**/*.css',
'lib/**/*',
'index.html'
]
}
},
// Setup a local server (using Node) with LiveReload enabled
connect: {
server: {
options: {
port: port,
base: {
path: baseFolder,
options: {
index: ['index.html']
}
},
hostname: hostname,
livereload: lrPort,
open: true
}
}
}
});
// Open local server and watch for file changes
grunt.registerTask('serve', ['portPick', 'connect', 'watch']);
// Default task(s).
grunt.registerTask('default', ['serve']);
};