-
Notifications
You must be signed in to change notification settings - Fork 0
/
gruntfile.js
78 lines (63 loc) · 2.65 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
module.exports = function (grunt) {
// Load Grunt tasks declared in the package.json file
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
// Configurable paths for the application
var appConfig = {
app: require('./bower.json').appPath || 'app',
dist: 'dist'
};
grunt.initConfig({
// grunt-contrib-connect will serve the files of the project
// on specified port and hostname
connect: {
all: {
options: {
port: 9000,
hostname: "0.0.0.0",
// No need for keepalive anymore as watch will keep Grunt running
//keepalive: true,
// Livereload needs connect to insert a cJavascript snippet
// in the pages it serves. This requires using a custom connect middleware
middleware: function (connect, options) {
return [
// Load the middleware provided by the livereload plugin
// that will take care of inserting the snippet
require('grunt-contrib-livereload/lib/utils').livereloadSnippet,
// Serve the project folder
connect.static('app')
];
}
}
}
},
// grunt-open will open your browser at the project's URL
open: {
all: {
// Gets the port from the connect configuration
path: 'http://localhost:9000/'
}
},
// grunt-regarde monitors the files and triggers livereload
// Surprisingly, livereload complains when you try to use grunt-contrib-watch instead of grunt-regarde
regarde: {
all: {
// This'll just watch the index.html file, you could add **/*.js or **/*.css
// to watch Javascript and CSS files too.
files: ['**/main.js', '**/*.css', 'app/*.html'],
// This configures the task that will run when the file change
tasks: ['livereload']
}
}
});
// Creates the `server` task
grunt.registerTask('serve', [
// Starts the livereload server to which the browser will connect to
// get notified of when it needs to reload
'livereload-start',
'connect',
// Connect is no longer blocking other tasks, so it makes more sense to open the browser after the server starts
'open',
// Starts monitoring the folders and keep Grunt alive
'regarde'
]);
};