-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGruntfile.coffee
143 lines (125 loc) · 3.13 KB
/
Gruntfile.coffee
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
'use strict'
# Load required Node.js modules
path = require 'path'
# Load LiveReload snippet
lrUtils = require 'grunt-contrib-livereload/lib/utils'
lrSnippet = lrUtils.livereloadSnippet
# Helper function for LiveReload
folderMount = (connect, point) ->
return connect.static path.resolve(point)
#
# Grunt main configuration
# ------------------------
module.exports = (grunt) ->
#
# Initial configuration object for Grunt
# passed to `grunt.initConfig()`
#
conf =
# Setup basic paths and read them by `<%= path.PROP %>`
path:
source: 'src'
publish: 'dist'
#
# Task to remove files & directories
#
# * [grunt-contrib-clean](https://github.com/gruntjs/grunt-contrib-clean)
#
clean:
options:
force: true
publish:
src: '<%= path.publish %>'
#
# Task to launch Connect & LiveReload static web server
#
# * [grunt-contrib-connect](https://github.com/gruntjs/grunt-contrib-connect)
# * [grunt-contrib-livereload](https://github.com/gruntjs/grunt-contrib-livereload)
#
connect:
publish:
options:
port: 50000
middleware: (connect, options) ->
return [lrSnippet, folderMount(connect, 'dist')]
#
# Task to copy files
#
# * [grunt-contrib-copy](https://github.com/gruntjs/grunt-contrib-copy)
#
copy:
source:
expand: true
cwd: '<%= path.source %>'
src: [
'**/*'
'!**/*.coffee'
'!**/*.jade'
'!**/*.jst'
'!**/*.less'
'!**/*.litcoffee'
'!**/*.sass'
'!**/*.scss'
'!**/*.styl'
]
dest: '<%= path.publish %>'
#
# Task to compile Jade
#
# * [grunt-contrib-jade](https://github.com/gruntjs/grunt-contrib-jade)
#
jade:
options:
pretty: true
data: grunt.file.readJSON 'package.json'
source:
expand: true
cwd: '<%= path.source %>'
src: '**/!(_)*.jade'
dest: '<%= path.publish %>'
ext: '.html'
#
# Task to observe file changes & fire up related tasks
#
# * [grunt-regarde](https://github.com/yeoman/grunt-regarde)
#
regarde:
source:
files: [
'<%= path.source %>/**/*'
'package.json'
]
tasks: [
'default'
'livereload'
]
#
# List of sequential tasks
# passed to `grunt.registerTask tasks.TASK`
#
tasks =
html: [
'jade'
]
watch: [
'livereload-start'
'connect'
'regarde'
]
default: [
'copy:source'
'html'
]
# Load Grunt plugins
grunt.loadNpmTasks 'grunt-contrib-clean'
grunt.loadNpmTasks 'grunt-contrib-connect'
grunt.loadNpmTasks 'grunt-contrib-copy'
grunt.loadNpmTasks 'grunt-contrib-jade'
grunt.loadNpmTasks 'grunt-contrib-livereload'
grunt.loadNpmTasks 'grunt-regarde'
# Load initial configuration being set up above
grunt.initConfig conf
# Regist sequential tasks being listed above
grunt.registerTask 'html', tasks.html
grunt.registerTask 'watch', tasks.watch
grunt.registerTask 'default', tasks.default